Class: Deserializer::Attribute::ValueAttribute

Inherits:
Base
  • Object
show all
Defined in:
lib/deserializer/attribute/value_attribute.rb

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_hash

Constructor Details

This class inherits a constructor from Deserializer::Attribute::Base

Instance Method Details

#value(params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/deserializer/attribute/value_attribute.rb', line 5

def value( params )
  value = params[key]

  if opts[:ignore_empty] && value.blank?
    return :ignore
  end
  
  if opts[:convert_with]
    method = opts[:convert_with]
    if object.respond_to? method
      return object.send method, value
    end
  end
  # other options go here
  
  value
end