-
-
Save anonymous/3114a48f9fc4963af0e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Main container class | |
class Container | |
def initialize | |
@incoming_msg = Message.new(configure_incoming) | |
@outgoing_msg = Message.new(configure_outgoing) | |
end | |
# These are individual configures for each message type | |
def configure_incoming | |
property :size, 'int', 0 | |
property :sender, 'string', '' | |
end | |
def configure_outgoing | |
property :size, 'int', 0 | |
property :receiver, 'string', '' | |
end | |
end | |
==================================================== | |
class Message | |
def initialize(configure) | |
# Not sure if this is the right syntax, haven't gotten this far... | |
configure.call | |
end | |
def property(name, type, default) | |
# do some property setting things | |
end | |
end | |
====================================================== | |
# If I wrap the property lines in a Proc things seem to be fine | |
# No complaints about not knowing what `property` is | |
def configure_incoming | |
incoming = Proc.new do | |
property :size, 'int', 0 | |
# ... | |
end | |
end | |
=========================================================== | |
# The reason I want to ignore Proc (if possible) is just because | |
# I think the nonProc version of configure_"" is cleaner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment