Class: Treaty::Entity::Builder
- Inherits:
-
Attribute::Builder::Base
- Object
- Attribute::Builder::Base
- Treaty::Entity::Builder
- Defined in:
- lib/treaty/entity/builder.rb
Overview
DSL builder for defining entity attributes.
Purpose
Provides Entity-specific implementation of the attribute builder. Creates Entity::Attribute::Attribute instances with required by default behavior (unlike Request/Response which have different defaults).
Inheritance
Extends Treaty::Entity::Attribute::Builder::Base which provides:
- DSL interface (string, integer, object, array, etc.)
- method_missing magic for type-based method calls
- Helper support (:required, :optional)
- Entity reuse via use_entity
Usage
Used internally by:
- Entity::Attribute::Attribute (when processing nested object/array blocks)
Default Behavior
Entity attributes default to required: true, meaning all fields
must be present unless explicitly marked :optional.
DSL Example
class UserEntity < Treaty::Entity::Base
object :user do
string :id # required by default
string :name # required by default
string :bio, :optional # explicitly optional
object :profile do
string :avatar_url
end
end
end
Methods
Implements abstract methods from base class:
create_attribute- Creates Entity::Attribute::Attributedeep_copy_attribute- Deep copies attribute for use_entity support
Instance Attribute Summary
Attributes inherited from Attribute::Builder::Base
#collection_of_attributes, #nesting_level
Method Summary
Methods inherited from Attribute::Builder::Base
#attribute, #initialize, #method_missing, #respond_to_missing?, #use_entity
Constructor Details
This class inherits a constructor from Treaty::Entity::Attribute::Builder::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Treaty::Entity::Attribute::Builder::Base