Module: FIRM::Serializable::SerializeInstanceMethods
- Defined in:
- lib/firm/serializable.rb,
lib/firm/serializer/xml.rb,
lib/firm/serializer/json.rb,
lib/firm/serializer/yaml.rb
Overview
extend instance serialization methods
Instance Method Summary collapse
-
#disable_serialize ⇒ void
Disables serialization for this object as a single property or as part of a property container (array or set).
- #encode_with(coder) ⇒ Object
- #init_with(coder) ⇒ Object
-
#serialize(io = nil, pretty: false, format: Serializable.default_format) ⇒ Object
Serialize this object.
-
#serialize_disabled? ⇒ true, false
Returns true if regular serialization for this object has been disabled, false otherwise (default).
Methods included from JSON::SerializeInstanceMethods
Methods included from XML::SerializeInstanceMethods
Instance Method Details
#disable_serialize ⇒ void
This method returns an undefined value.
Disables serialization for this object as a single property or as part of a property container (array or set).
554 555 556 557 |
# File 'lib/firm/serializable.rb', line 554 def disable_serialize # by default unset (nil) so serializing enabled @serialize_disabled = true end |
#encode_with(coder) ⇒ Object
117 118 119 |
# File 'lib/firm/serializer/yaml.rb', line 117 def encode_with(coder) for_serialize(coder) end |
#init_with(coder) ⇒ Object
121 122 123 124 |
# File 'lib/firm/serializer/yaml.rb', line 121 def init_with(coder) from_serialized(coder.map) finalize_from_serialized end |
#serialize(pretty: false, format: Serializable.default_format) ⇒ String #serialize(io, pretty: false, format: Serializable.default_format) ⇒ IO
Serialize this object
539 540 541 |
# File 'lib/firm/serializable.rb', line 539 def serialize(io = nil, pretty: false, format: Serializable.default_format) Serializable[format].dump(self, io, pretty: pretty) end |
#serialize_disabled? ⇒ true, false
Returns true if regular serialization for this object has been disabled, false otherwise (default). Disabled serialization can be overridden for single objects (not objects maintained in property containers like arrays and sets).
547 548 549 |
# File 'lib/firm/serializable.rb', line 547 def serialize_disabled? !!@serialize_disabled # true for any value but false end |