Created
September 16, 2011 00:34
-
-
Save coreypurcell/1220885 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| attr_accessor :jmessage | |
| def initialize(message=nil, options={}) | |
| if message.kind_of? org.jgroups.Message | |
| @jmessage = message | |
| else | |
| @jmessage = org.jgroups.Message.new(options[:destination], | |
| options[:source], | |
| message) | |
| end | |
| end | |
| def self.from_jmessage(jmessage) | |
| self.new.jmessage = jmessage | |
| end | |
| # So other classes call | |
| Message.new(jmessage) | |
| Message.new("Here is my message" | |
| # | |
| Message.from_jmessage(jmessage) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rather than provide so many options, I think I'd pick one way and stick with it, especially if this class is never instantiated by users of the library (do they?). Since you want to wrap the org.jgroups.Message with your Message class, I think I'd make the initializer look like:
This is not the end-all-be-all solution though, so do what makes sense for your library.