Class: Treaty::Action::Request::Entity
- Inherits:
-
Object
- Object
- Treaty::Action::Request::Entity
- Includes:
- Entity::Attribute::DSL
- Defined in:
- lib/treaty/action/request/entity.rb
Overview
Internal entity class for request attribute definitions.
Purpose
Provides DSL interface for defining request attributes when using
inline block syntax in treaty definitions. Serves as the anonymous
class base when request do ... end is used.
Usage
Created internally by:
- Request::Factory (when using inline DSL blocks)
DSL Interface
Includes Treaty::Entity::Attribute::DSL which provides:
- Type methods: string, integer, boolean, date, time, datetime
- Structure methods: object, array
- Helper support: :required, :optional
Difference from Treaty::Entity::Base
While Treaty::Entity::Base creates standalone entity classes, Request::Entity creates Request-specific attributes with:
- Required by default behavior
- Request::Attribute::Attribute instances
Example
# When you write:
version 1 do
request do
object :post do
string :title, :required
end
end
end
# Factory creates: Class.new(Request::Entity)
# and calls string, object etc. on it