Module: Castkit::DSL::DataObject
- Included in:
- Castkit::DataObject
- Defined in:
- lib/castkit/dsl/data_object.rb,
lib/castkit/dsl/data_object/plugins.rb,
lib/castkit/dsl/data_object/contract.rb,
lib/castkit/dsl/data_object/introspection.rb,
lib/castkit/dsl/data_object/serialization.rb,
lib/castkit/dsl/data_object/deserialization.rb
Overview
Provides the complete DSL used by Castkit data objects.
This module can be included into any class to make it behave like a ‘Castkit::DataObject` without requiring subclassing. It wires in the full attribute DSL, type system, contract support, plugin lifecycle, and (de)serialization logic.
This is what powers ‘Castkit::DataObject` internally, and is intended for advanced use cases where composition is preferred over inheritance.
When included, this module:
-
‘extend`s:
-
Core::Config – configuration and context behavior
-
Core::Attributes – the DSL for declaring attributes
-
Core::AttributeTypes – support for custom type resolution
-
Contract – validation contract hooks
-
Plugins – plugin hooks and lifecycle events
-
-
‘include`s:
-
Serialization – ‘#to_h`, `#as_json`, etc.
-
Deserialization – ‘from_h`, `from_json`, etc.
-
Defined Under Namespace
Modules: Contract, Deserialization, Introspection, Plugins, Serialization
Class Method Summary collapse
-
.included(base) ⇒ void
Hook triggered when the module is included.
Class Method Details
.included(base) ⇒ void
This method returns an undefined value.
Hook triggered when the module is included.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/castkit/dsl/data_object.rb', line 50 def self.included(base) base.include(Cattri) base.extend(Castkit::Core::Config) base.extend(Castkit::Core::Attributes) base.extend(Castkit::Core::AttributeTypes) base.extend(Castkit::DSL::DataObject::Contract) base.extend(Castkit::DSL::DataObject::Plugins) base.extend(Castkit::DSL::DataObject::Introspection) base.include(Castkit::DSL::DataObject::Serialization) base.include(Castkit::DSL::DataObject::Deserialization) end |