Module: Contactually::Models::Model::ClassMethods
- Defined in:
- lib/contactually/models/model.rb
Instance Attribute Summary collapse
-
#field_list ⇒ Object
Returns the value of attribute field_list.
Instance Method Summary collapse
Instance Attribute Details
#field_list ⇒ Object
Returns the value of attribute field_list.
84 85 86 |
# File 'lib/contactually/models/model.rb', line 84 def field_list @field_list end |
Instance Method Details
#field(field_name, type) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/contactually/models/model.rb', line 86 def field(field_name, type) register_field field_name private_method = define_method "#{field_name}=" do |value| instance_variable_set "@#{field_name}", type_cast(value, type) end private private_method end |
#register_field(field_name) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/contactually/models/model.rb', line 99 def register_field(field_name) class_eval do attr_reader field_name end self.field_list << field_name end |