Class: EmbeddedModel::Type
- Inherits:
-
ActiveRecord::Type::Internal::AbstractJson
- Object
- ActiveRecord::Type::Internal::AbstractJson
- EmbeddedModel::Type
- Defined in:
- lib/embedded_model/type.rb
Instance Method Summary collapse
- #cast(attrs) ⇒ Object
- #deserialize(json) ⇒ Object
-
#initialize(&builder) ⇒ Type
constructor
A new instance of Type.
- #serialize(obj) ⇒ Object
Constructor Details
#initialize(&builder) ⇒ Type
Returns a new instance of Type.
3 4 5 |
# File 'lib/embedded_model/type.rb', line 3 def initialize(&builder) @builder = builder end |
Instance Method Details
#cast(attrs) ⇒ Object
7 8 9 |
# File 'lib/embedded_model/type.rb', line 7 def cast(attrs) @builder.call(attrs) end |
#deserialize(json) ⇒ Object
15 16 17 |
# File 'lib/embedded_model/type.rb', line 15 def deserialize(json) cast(super) end |
#serialize(obj) ⇒ Object
11 12 13 |
# File 'lib/embedded_model/type.rb', line 11 def serialize(obj) super(obj.as_json) end |