Module: FatSecret::Relations::BelongsTo::ClassMethods
- Defined in:
- lib/fat_secret/relations/belongs_to.rb
Instance Method Summary collapse
Instance Method Details
#belongs_to(type, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fat_secret/relations/belongs_to.rb', line 7 def belongs_to(type, = {}) class_eval do attribute "#{type}_id", type: Integer attr_reader type end define_method "#{type}=" do |arg| instance_variable_set(:"@#{type}", arg) arg.send("#{self.class.name.split('::').last.downcase.pluralize}") << self end end |