Class: HoboFields::FieldDeclarationDsl
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- HoboFields::FieldDeclarationDsl
- 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
Constructor Details
#initialize(model) ⇒ FieldDeclarationDsl
Returns a new instance of FieldDeclarationDsl.
5 6 7 |
# File 'lib/hobo_fields/field_declaration_dsl.rb', line 5 def initialize(model) @model = model end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
23 24 25 |
# File 'lib/hobo_fields/field_declaration_dsl.rb', line 23 def method_missing(name, *args) field(name, *args) end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
9 10 11 |
# File 'lib/hobo_fields/field_declaration_dsl.rb', line 9 def model @model end |
Instance Method Details
#field(name, type, *args) ⇒ Object
18 19 20 |
# File 'lib/hobo_fields/field_declaration_dsl.rb', line 18 def field(name, type, *args) @model.declare_field(name, type, *args) end |
#timestamps ⇒ Object
12 13 14 15 |
# File 'lib/hobo_fields/field_declaration_dsl.rb', line 12 def field(:created_at, :datetime) field(:updated_at, :datetime) end |