module NinjaModel::AttributeMethods::ClassMethods
Public Instance Methods
attribute(name, data_type, *args)
click to toggle source
# File lib/ninja_model/attribute_methods.rb, line 33 def attribute(name, data_type, *args) name = name.to_s opts = args.extract_options! 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
attribute_names()
click to toggle source
# File lib/ninja_model/attribute_methods.rb, line 54 def attribute_names @attribute_names ||= model_attributes.map { |attribute| attribute.name } end
Also aliased as: column_names
columns()
click to toggle source
# File lib/ninja_model/attribute_methods.rb, line 44 def columns model_attributes end
model_attributes_hash()
click to toggle source
# File lib/ninja_model/attribute_methods.rb, line 48 def model_attributes_hash @attributes_hash ||= HashWithIndifferentAccess[model_attributes.map { |attribute| [attribute.name, attribute] }] end
Also aliased as: columns_hash