Class: Serega::AttributeValueResolvers::Delegate

Inherits:
Object
  • Object
show all
Defined in:
lib/serega/attribute_value_resolvers/delegate.rb

Overview

Value resolver class for attributes with :delegate (without :allow_nil) option

Instance Method Summary collapse

Constructor Details

#initialize(delegate_to, method_name) ⇒ Delegate

Returns a new instance of Delegate.



53
54
55
56
# File 'lib/serega/attribute_value_resolvers/delegate.rb', line 53

def initialize(delegate_to, method_name)
  @delegate_to = delegate_to
  @method_name = method_name
end

Instance Method Details

#call(object) ⇒ Object

Delegates method call to another object

Parameters:

  • object (Object)

    the object to delegate from

Returns:

  • (Object)

    result of delegated method call



64
65
66
# File 'lib/serega/attribute_value_resolvers/delegate.rb', line 64

def call(object)
  object.public_send(@delegate_to).public_send(@method_name)
end