Module: Treaty::Entity::Attribute::DSL::ClassMethods
- Defined in:
- lib/treaty/entity/attribute/dsl.rb
Instance Method Summary collapse
-
#attribute(name, type, *helpers, **options, &block) ⇒ void
Defines an attribute with explicit type.
-
#collection_of_attributes ⇒ Treaty::Entity::Attribute::Collection
Returns collection of attributes for this class.
-
#method_missing(type, *helpers, **options, &block) ⇒ void
Handles DSL methods like
string :namewhere method name is the type. - #respond_to_missing?(name) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(type, *helpers, **options, &block) ⇒ void
This method returns an undefined value.
Handles DSL methods like string :name where method name is the type
61 62 63 64 65 66 67 68 69 |
# File 'lib/treaty/entity/attribute/dsl.rb', line 61 def method_missing(type, *helpers, **, &block) name = helpers.shift # If no attribute name provided, this is not an attribute definition # Pass to super to handle it properly (e.g., for methods like 'info', 'call!', etc.) return super if name.nil? attribute(name, type, *helpers, **, &block) end |
Instance Method Details
#attribute(name, type, *helpers, **options, &block) ⇒ void
This method returns an undefined value.
Defines an attribute with explicit type
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/treaty/entity/attribute/dsl.rb', line 35 def attribute(name, type, *helpers, **, &block) collection_of_attributes << create_attribute( name, type, *helpers, nesting_level: 0, **, &block ) end |
#collection_of_attributes ⇒ Treaty::Entity::Attribute::Collection
Returns collection of attributes for this class
49 50 51 |
# File 'lib/treaty/entity/attribute/dsl.rb', line 49 def collection_of_attributes @collection_of_attributes ||= Treaty::Entity::Attribute::Collection.new end |
#respond_to_missing?(name) ⇒ Boolean
71 72 73 |
# File 'lib/treaty/entity/attribute/dsl.rb', line 71 def respond_to_missing?(name, *) super end |