Method: Infuser::Models::Base.belongs_to

Defined in:
lib/infuser/models/base.rb

.belongs_to(type) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/infuser/models/base.rb', line 45

def belongs_to type
  type = type.to_s.underscore

  define_method "#{type}=" do |arg|
    update_association(type, arg)
  end

  define_method "clear_#{type}" do
    clear_association(type)
  end

  define_method "#{type}" do
    fetch_association(type)
  end
end