Class: EasySerializer::Attribute

Inherits:
Field
  • Object
show all
Includes:
Helpers
Defined in:
lib/easy_serializer/attribute.rb

Instance Attribute Summary

Attributes inherited from Field

#block, #name, #options

Instance Method Summary collapse

Methods included from Helpers

#option_to_value

Methods inherited from Field

#cache_key, #cache_options, #catch?, #get_value, #nested_serializer, #send_method, #serialize!, #serializer, #serializer?

Instance Method Details

#default?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/easy_serializer/attribute.rb', line 5

def default?
  options[:default]
end

#get_default(object, serializer) ⇒ Object



9
10
11
12
# File 'lib/easy_serializer/attribute.rb', line 9

def get_default(object, serializer)
  return unless default?
  option_to_value(options[:default], object, serializer)
end