Method: NinjaModel::AttributeMethods::ClassMethods#attribute
- Defined in:
- lib/ninja_model/attribute_methods.rb
#attribute(name, data_type, *args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ninja_model/attribute_methods.rb', line 33 def attribute(name, data_type, *args) name = name.to_s opts = args. primary = opts.delete(:primary_key) self.primary_key = name if primary.eql?(true) default = args.first unless args.blank? new_attr = Attribute.new(name, data_type, opts) self.model_attributes = model_attributes + [new_attr] define_attribute_method name end |