module Opisator
Attributes
contract[RW]
Public Instance Methods
call()
click to toggle source
# File lib/opisator.rb, line 40 def call return self.send(action_name) unless has_call_method? self.send(call_method) end
define_method_for(action)
click to toggle source
# File lib/opisator.rb, line 22 def define_method_for(action) define_method method_by(action) do @contract = Opisator::Defaults::Contract @interactor = Opisator::Defaults::Interactor @presenter = Opisator::Defaults::Presenter self.send(action) contract_params = @contract.new.call(params) result = @interactor.new.call(contract_params) render @presenter.new.call(result) end end
method_by(action)
click to toggle source
# File lib/opisator.rb, line 18 def method_by(action) "call_#{action}" end
opisator_for(*actions)
click to toggle source
# File lib/opisator.rb, line 14 def opisator_for(*actions) actions.each { |action| define_method_for action } end
Private Instance Methods
call_method()
click to toggle source
# File lib/opisator.rb, line 48 def call_method instance_method_by(action_name) end
has_call_method?()
click to toggle source
# File lib/opisator.rb, line 52 def has_call_method? self.class.method_defined? call_method end
instance_method_by(action)
click to toggle source
# File lib/opisator.rb, line 56 def instance_method_by(action) self.class.send(:method_by, action) end