Class: Treaty::Action::Response::Entity
- Inherits:
-
Object
- Object
- Treaty::Action::Response::Entity
- Includes:
- Entity::Attribute::DSL
- Defined in:
- lib/treaty/action/response/entity.rb
Overview
Internal entity class for response attribute definitions.
Purpose
Provides DSL interface for defining response attributes when using
inline block syntax in treaty definitions. Serves as the anonymous
class base when response STATUS do ... end is used.
Usage
Created internally by:
- Response::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, Response::Entity creates Response-specific attributes with:
- Optional by default behavior
- Response::Attribute::Attribute instances
Example
# When you write:
version 1 do
response 201 do
object :post do
string :id
string :title
end
end
end
# Factory creates: Class.new(Response::Entity)
# and calls string, object etc. on it