Module: Clot::DropAssociation

Included in:
BaseDrop
Defined in:
lib/clot/base_drop.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to(*args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/clot/base_drop.rb', line 3

def belongs_to(*args)
  args.each do |sym|
    belongs_to = %{
    def #{sym}
      @source.#{sym}
    end
    def #{sym}_id
      @source.#{sym}_id
    end
    }
    class_eval belongs_to
  end
end

#has_many(*args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/clot/base_drop.rb', line 17

def has_many(*args)
  args.each do |sym|
    has_many = %{
    def #{sym}
      @source.#{sym}
    end

     def #{sym.to_s.singularize}_ids
        @source.#{sym.to_s.singularize}_ids
     end
    }
    class_eval has_many
  end

end