Class: Theatre::CallbackDefinitionLoader
- Defined in:
- lib/theatre/callback_definition_loader.rb
Overview
This class provides the a wrapper aroung which an events.rb file can be instance_eval’d.
Defined Under Namespace
Classes: BlankSlateMessageRecorder
Instance Attribute Summary collapse
-
#root_name ⇒ Object
readonly
Returns the value of attribute root_name.
-
#theatre ⇒ Object
readonly
Returns the value of attribute theatre.
Instance Method Summary collapse
- #anonymous_recorder ⇒ Object
-
#initialize(theatre, root_name = :events) ⇒ CallbackDefinitionLoader
constructor
A new instance of CallbackDefinitionLoader.
-
#load_events_code(code) ⇒ Object
Parses the given Ruby source code and returns this object.
-
#load_events_file(file) ⇒ Object
Parses the given Ruby source code file and returns this object.
Constructor Details
#initialize(theatre, root_name = :events) ⇒ CallbackDefinitionLoader
Returns a new instance of CallbackDefinitionLoader.
9 10 11 12 13 14 |
# File 'lib/theatre/callback_definition_loader.rb', line 9 def initialize(theatre, root_name=:events) @theatre = theatre @root_name = root_name create_recorder_method root_name end |
Instance Attribute Details
#root_name ⇒ Object (readonly)
Returns the value of attribute root_name.
8 9 10 |
# File 'lib/theatre/callback_definition_loader.rb', line 8 def root_name @root_name end |
#theatre ⇒ Object (readonly)
Returns the value of attribute theatre.
8 9 10 |
# File 'lib/theatre/callback_definition_loader.rb', line 8 def theatre @theatre end |
Instance Method Details
#anonymous_recorder ⇒ Object
16 17 18 |
# File 'lib/theatre/callback_definition_loader.rb', line 16 def anonymous_recorder BlankSlateMessageRecorder.new(&method(:callback_registered)) end |
#load_events_code(code) ⇒ Object
Parses the given Ruby source code and returns this object.
NOTE: Only use this if you’re generating the code yourself! If you’re loading a file from the filesystem, you should use load_events_file() since load_events_file() will properly attribute errors in the code to the file from which the code was loaded.
40 41 42 43 |
# File 'lib/theatre/callback_definition_loader.rb', line 40 def load_events_code(code) instance_eval code self end |