Skip to content

Instantly share code, notes, and snippets.

@davybrion
Created September 15, 2012 13:24
Show Gist options
  • Save davybrion/3727849 to your computer and use it in GitHub Desktop.
Save davybrion/3727849 to your computer and use it in GitHub Desktop.
code snippets for "Compiler|Interpreter Warnings Are Important Learning Opportunities" post
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
subscribed.should be_true
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
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