Class: SerializableAttributes::Array
- Inherits:
-
AttributeType
- Object
- AttributeType
- SerializableAttributes::Array
- Defined in:
- lib/serializable_attributes/types.rb
Instance Method Summary collapse
- #encode(input) ⇒ Object
-
#initialize(options = {}) ⇒ Array
constructor
A new instance of Array.
- #parse(input) ⇒ Object
Methods inherited from AttributeType
Constructor Details
#initialize(options = {}) ⇒ Array
Returns a new instance of Array.
74 75 76 77 |
# File 'lib/serializable_attributes/types.rb', line 74 def initialize( = {}) super @item_type = type_for([:type] || "String") end |
Instance Method Details
#encode(input) ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/serializable_attributes/types.rb', line 89 def encode(input) if input.nil? nil elsif input.blank? [] else input.map! { |item| @item_type.encode(item) } end end |
#parse(input) ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/serializable_attributes/types.rb', line 79 def parse(input) if input.nil? nil elsif input.blank? [] else input.map { |item| @item_type.parse(item) } end end |