Class: Command::DSL::Argument::SubjectDeferral

Inherits:
Object
  • Object
show all
Defined in:
lib/command-set/dsl.rb

Instance Method Summary collapse

Constructor Details

#initializeSubjectDeferral

Returns a new instance of SubjectDeferral.



177
178
179
# File 'lib/command-set/dsl.rb', line 177

def initialize
  @deferred_calls = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



172
173
174
175
# File 'lib/command-set/dsl.rb', line 172

def method_missing(name, *args, &block)
  @deferred_calls << [name, args, block]
  return self
end

Instance Method Details

#realize(subject) ⇒ Object



185
186
187
188
189
190
191
192
193
194
# File 'lib/command-set/dsl.rb', line 185

def realize(subject)
  return @deferred_calls.inject(subject) do |obj, call|
    obj = obj.__send__(call[0], *call[1])
    if call[2].nil?
      obj
    else
      call[2].call(obj)
    end
  end
end

#subject_requirementsObject



181
182
183
# File 'lib/command-set/dsl.rb', line 181

def subject_requirements
  return [@deferred_calls.first.first]
end