Module: Graphiti::ActiveGraph::Util::SerializerAttribute

Defined in:
lib/graphiti/active_graph/util/serializer_attribute.rb

Instance Method Summary collapse

Instance Method Details

#wrap_proc(inner) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/graphiti/active_graph/util/serializer_attribute.rb', line 4

def wrap_proc(inner)
  typecast_ref = typecast(Graphiti::Types[@attr[:type]][:read])
  ->(serializer_instance = nil) {
    val = serializer_instance.instance_eval(&inner)
    if Graphiti.config.typecast_reads && inner.nil?
      typecast_ref.call(val)
    else
      val
    end
  }
end