class Deserializer::Attribute::Base

Attributes

name[RW]
object[RW]
opts[RW]
value[RW]

Public Class Methods

new( name, opts = {}, object ) click to toggle source
# File lib/deserializer/attribute/base.rb, line 7
def initialize( name, opts = {}, object )
  self.name   = name
  self.opts   = opts
  self.object = object
end

Public Instance Methods

to_hash( params ) click to toggle source

has_one :whatever; where def wahtever{ object } { object }

# File lib/deserializer/attribute/base.rb, line 21
def to_hash( params )
  return {} unless params.has_key? key
  tuple( params )
end

Private Instance Methods

key() click to toggle source
# File lib/deserializer/attribute/base.rb, line 31
def key
  @key ||= opts.fetch :key, name
end
tuple( params = {} ) click to toggle source
# File lib/deserializer/attribute/base.rb, line 35
def tuple( params = {} )
  value = value( params )
  if value == :ignore
    {}
  else
    { name => value }
  end
end