Class: RSchema::Coercers::FixedHash::DefaultArraysToEmpty
- Inherits:
-
Object
- Object
- RSchema::Coercers::FixedHash::DefaultArraysToEmpty
- Defined in:
- lib/rschema/coercers/fixed_hash/default_arrays_to_empty.rb
Overview
The HTTP standard says that when a form is submitted, all unchecked check boxes will not be sent to the server. That is, they will not be present at all in the params hash.
This class coerces these missing values into an empty array, where an array is expected.
Instance Attribute Summary collapse
-
#hash_attributes ⇒ Object
readonly
Returns the value of attribute hash_attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #call(value) ⇒ Object
-
#initialize(fixed_hash_schema) ⇒ DefaultArraysToEmpty
constructor
A new instance of DefaultArraysToEmpty.
Constructor Details
#initialize(fixed_hash_schema) ⇒ DefaultArraysToEmpty
Returns a new instance of DefaultArraysToEmpty.
20 21 22 23 |
# File 'lib/rschema/coercers/fixed_hash/default_arrays_to_empty.rb', line 20 def initialize(fixed_hash_schema) #TODO: make fixed hash attributes frozen, and eliminate dup @hash_attributes = fixed_hash_schema.attributes.map(&:dup) end |
Instance Attribute Details
#hash_attributes ⇒ Object (readonly)
Returns the value of attribute hash_attributes.
14 15 16 |
# File 'lib/rschema/coercers/fixed_hash/default_arrays_to_empty.rb', line 14 def hash_attributes @hash_attributes end |
Class Method Details
.build(schema) ⇒ Object
16 17 18 |
# File 'lib/rschema/coercers/fixed_hash/default_arrays_to_empty.rb', line 16 def self.build(schema) new(schema) end |