Class: Gluer::DSL
- Inherits:
-
Object
- Object
- Gluer::DSL
- Defined in:
- lib/gluer/dsl.rb
Class Method Summary collapse
- .add_registration_definition(name, definition) ⇒ Object
- .clear ⇒ Object
- .get_registration_definition(name) ⇒ Object
Instance Method Summary collapse
-
#initialize(context, registration_collection) ⇒ DSL
constructor
A new instance of DSL.
Constructor Details
#initialize(context, registration_collection) ⇒ DSL
Returns a new instance of DSL.
42 43 44 45 |
# File 'lib/gluer/dsl.rb', line 42 def initialize(context, registration_collection) @context = context @registration_collection = registration_collection end |
Class Method Details
.add_registration_definition(name, definition) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/gluer/dsl.rb', line 17 def add_registration_definition(name, definition) defined_registrations[name] = definition define_method(name) do |*args, &block| definition = DSL.get_registration_definition(name) registration = Registration.new(definition, @context, args, block) @registration_collection.add(registration) end end |
.clear ⇒ Object
31 32 33 |
# File 'lib/gluer/dsl.rb', line 31 def clear @defined_registrations = nil end |
.get_registration_definition(name) ⇒ Object
27 28 29 |
# File 'lib/gluer/dsl.rb', line 27 def get_registration_definition(name) defined_registrations.fetch(name) end |