Skip to content

Instantly share code, notes, and snippets.

/method_pass.rb Secret

Created October 6, 2014 14:52
Show Gist options
  • Save anonymous/3114a48f9fc4963af0e1 to your computer and use it in GitHub Desktop.
Save anonymous/3114a48f9fc4963af0e1 to your computer and use it in GitHub Desktop.
# 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