Class: ParamsDeserializer::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/params_deserializers/attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_name, options = {}) ⇒ Attribute

Returns a new instance of Attribute.



34
35
36
37
38
39
# File 'lib/params_deserializers/attribute.rb', line 34

def initialize(original_name, options = {})
  @original_name = original_name
  @name = options[:rename_to] || @original_name
  @ignored = options[:ignored]
  @present_if = options[:present_if] || -> { params_root.has_key?(original_name) }
end

Instance Attribute Details

#ignoredObject (readonly)

Returns the value of attribute ignored.



32
33
34
# File 'lib/params_deserializers/attribute.rb', line 32

def ignored
  @ignored
end

#nameObject (readonly)

Returns the value of attribute name.



32
33
34
# File 'lib/params_deserializers/attribute.rb', line 32

def name
  @name
end

#original_nameObject (readonly)

Returns the value of attribute original_name.



32
33
34
# File 'lib/params_deserializers/attribute.rb', line 32

def original_name
  @original_name
end

#present_ifObject (readonly)

Returns the value of attribute present_if.



32
33
34
# File 'lib/params_deserializers/attribute.rb', line 32

def present_if
  @present_if
end