Module: Upmin::ActiveRecord::Association
- Defined in:
- lib/upmin/active_record/association.rb
Instance Method Summary collapse
Instance Method Details
#collection? ⇒ Boolean
25 26 27 28 29 30 31 32 33 |
# File 'lib/upmin/active_record/association.rb', line 25 def collection? if reflection return reflection.collection? elsif value return value.responds_to?(:each) else return false end end |
#type ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/upmin/active_record/association.rb', line 4 def type return @type if defined?(@type) if reflection @type = reflection.foreign_type.to_s.gsub(/_type$/, "") if collection? @type = @type.pluralize.to_sym else @type = @type.to_sym end else @type = :unknown end if @type == :unknown @type = infer_type_from_value end return @type end |