Class: Serega::AttributeValueResolvers::DelegateResolver

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

Overview

Builds value resolver class for attributes with :delegate option

Class Method Summary collapse

Class Method Details

.get(delegate_to, method_name, allow_nil) ⇒ Delegate, DelegateAllowNil

Creates resolver that delegates method call to another object

Parameters:

  • delegate_to (Symbol)

    method to call on object to get delegated object

  • method_name (Symbol)

    method to call on delegated object

  • allow_nil (Boolean)

    whether to use safe navigation when delegated object is nil

Returns:



20
21
22
# File 'lib/serega/attribute_value_resolvers/delegate.rb', line 20

def self.get(delegate_to, method_name, allow_nil)
  allow_nil ? DelegateAllowNil.new(delegate_to, method_name) : Delegate.new(delegate_to, method_name)
end