Module: Ardm::ActiveRecord::Associations::ClassMethods
- Defined in:
- lib/ardm/active_record/associations.rb
Instance Method Summary collapse
Instance Method Details
#belongs_to(field, options = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/ardm/active_record/associations.rb', line 43 def belongs_to(field, ={}) .delete(:default) .delete(:required) opts = Ardm::ActiveRecord::Associations.(self, ) super field, opts assoc = reflect_on_association(field) property assoc.foreign_key, Ardm::Property::Integer nil end |
#has(count, name, *args) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ardm/active_record/associations.rb', line 57 def has(count, name, *args) = args.shift || {} if String === # has n, :name, 'Class', options: 'here' = (args.last || {}).merge(:model => ) end unless Hash === raise ArgumentError, "bad has #{count} options format #{.inspect}" end [:order] = Ardm::ActiveRecord::Query.order(self, [:order]) if [:order] opts = Ardm::ActiveRecord::Associations.(self, , :through, :order) case count when 1 then has_one name, opts when "many" then has_many name, opts end end |
#n ⇒ Object
53 54 55 |
# File 'lib/ardm/active_record/associations.rb', line 53 def n "many" end |