Class: Castkit::DefaultSerializer
- Inherits:
-
Serializer
- Object
- Serializer
- Castkit::DefaultSerializer
- Defined in:
- lib/castkit/default_serializer.rb
Overview
Default serializer for Castkit::DataObject instances.
Serializes attributes based on access rules, nil/blank filtering, and nested structure.
Constant Summary collapse
- SKIP_ATTRIBUTE =
:__castkit_skip_attribute
Instance Attribute Summary collapse
-
#attributes ⇒ Hash{Symbol => Castkit::Attribute}
readonly
Attributes to serialize.
-
#options ⇒ Hash
readonly
Serialization options (root key, ignore_nil, etc.).
Attributes inherited from Serializer
Instance Method Summary collapse
-
#call ⇒ Hash
Returns the serialized object as a Hash.
Methods inherited from Serializer
Instance Attribute Details
#attributes ⇒ Hash{Symbol => Castkit::Attribute} (readonly)
Returns attributes to serialize.
13 14 15 |
# File 'lib/castkit/default_serializer.rb', line 13 def attributes @attributes end |
#options ⇒ Hash (readonly)
Returns serialization options (root key, ignore_nil, etc.).
16 17 18 |
# File 'lib/castkit/default_serializer.rb', line 16 def end |
Instance Method Details
#call ⇒ Hash
Returns the serialized object as a Hash.
Includes root wrapping if configured.
23 24 25 26 |
# File 'lib/castkit/default_serializer.rb', line 23 def call result = serialize_attributes [:root] ? { [:root].to_sym => result } : result end |