Class: Gluer::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/gluer/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

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

.clearObject



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