Module: Hanuman::Shortcuts
Instance Method Summary collapse
- #add_shortcut_method_for(method_name, builder_type) ⇒ Object
- #builder_shortcut(builder_type, label, *args, &blk) ⇒ Object
- #registry ⇒ Object
Instance Method Details
#add_shortcut_method_for(method_name, builder_type) ⇒ Object
23 24 25 |
# File 'lib/hanuman.rb', line 23 def add_shortcut_method_for(method_name, builder_type) self.define_singleton_method(method_name){ |label, *args, &blk| builder_shortcut(builder_type, label, *args, &blk) } end |
#builder_shortcut(builder_type, label, *args, &blk) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/hanuman.rb', line 13 def builder_shortcut(builder_type, label, *args, &blk) if GlobalRegistry.registered?(label) builder = GlobalRegistry.retrieve(label) else builder = builder_type.receive(label: label) end GlobalRegistry.decorate_with_registry(builder) if builder.is_a?(GraphBuilder) builder.define(*args, &blk) end |
#registry ⇒ Object
27 |
# File 'lib/hanuman.rb', line 27 def registry() Hanuman::GlobalRegistry ; end |