Class: HoboFields::FieldDeclarationDsl
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- HoboFields::FieldDeclarationDsl
- Includes:
- Types::EnumString::DeclarationHelper
- Defined in:
- lib/hobo_fields/field_declaration_dsl.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #field(name, type, *args) ⇒ Object
-
#initialize(model) ⇒ FieldDeclarationDsl
constructor
A new instance of FieldDeclarationDsl.
- #method_missing(name, *args) ⇒ Object
- #timestamps ⇒ Object
Methods included from Types::EnumString::DeclarationHelper
Constructor Details
#initialize(model) ⇒ FieldDeclarationDsl
Returns a new instance of FieldDeclarationDsl.
9 10 11 |
# File 'lib/hobo_fields/field_declaration_dsl.rb', line 9 def initialize(model) @model = model end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
27 28 29 |
# File 'lib/hobo_fields/field_declaration_dsl.rb', line 27 def method_missing(name, *args) field(name, args.first, *args.rest) end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
13 14 15 |
# File 'lib/hobo_fields/field_declaration_dsl.rb', line 13 def model @model end |
Instance Method Details
#field(name, type, *args) ⇒ Object
22 23 24 |
# File 'lib/hobo_fields/field_declaration_dsl.rb', line 22 def field(name, type, *args) @model.declare_field(name, type, *args) end |
#timestamps ⇒ Object
16 17 18 19 |
# File 'lib/hobo_fields/field_declaration_dsl.rb', line 16 def field(:created_at, :datetime) field(:updated_at, :datetime) end |