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.



200
201
202
# File 'lib/command-set/dsl.rb', line 200

def initialize
  @deferred_calls = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



195
196
197
198
# File 'lib/command-set/dsl.rb', line 195

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

Instance Method Details

#realize(subject) ⇒ Object



208
209
210
211
212
213
214
215
216
217
# File 'lib/command-set/dsl.rb', line 208

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



204
205
206
# File 'lib/command-set/dsl.rb', line 204

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