Module: EasySerializer::Helpers

Included in:
Attribute, AttributeSerializer, Base, Cacher::Template, Field, RootCacher
Defined in:
lib/easy_serializer/helpers.rb

Instance Method Summary collapse

Instance Method Details

#option_to_value(option, value, instance = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/easy_serializer/helpers.rb', line 3

def option_to_value(option, value, instance = nil)
  inst = instance || self
  case option
  when Proc
    inst.instance_exec value, &option
    # TODO
    # Will be nice to be able to add classes in the options responding to call
    # for complex algorithms.
    # when ->(opt) { opt.respond_to?(:call) }
  else
    option
  end
end