Created
September 15, 2012 13:24
-
-
Save davybrion/3727849 to your computer and use it in GitHub Desktop.
code snippets for "Compiler|Interpreter Warnings Are Important Learning Opportunities" post
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
it "should know about the subscribed method for the correct event" do | |
@publisher.subscribe :first_event, method(:first_event_handler) | |
subscribed = @publisher.subscribed? :first_event, method(:first_event_handler) | |
subscribed.should == true | |
end |
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
subscribed.should be_true |
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
define_method getter do | |
event = instance_variable_get variable | |
if event == nil | |
event = Event.new(symbol.to_s) | |
instance_variable_set variable, event | |
end | |
event | |
end |
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
define_method getter do | |
if !instance_variable_defined? variable | |
event = Event.new(symbol.to_s) | |
instance_variable_set variable, event | |
end | |
instance_variable_get variable | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment