codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
# Normal implementation module Messages include Beefcake::Message module Type SomeAction = 0 end class ActionMessage module ActionFlag Action1 = 0 Action2 = 1 Action3 = 2 end required :actions, ActionFlag, 1 end end send_packet Messages::Type::SomeAction, Messages::ActionMessage.new(actions: Messages::ActionMessage::ActionFlag::Action1 | Messages::ActionMessage::ActionFlag::Action2) # Ideal DSL implementation define_protocol do type :some_action, :ActionMessage message :ActionMessage do flags :ActionFlag, :action_1, :action_2, :action_3 required :actions, ActionFlag, 1 end end send_packet :some_action, actions: [:action_1, :action_2]
Private
[
?
]
Run code
Submit