Module: XBar::Association::ClassMethods

Defined in:
lib/xbar/association.rb

Instance Method Summary collapse

Instance Method Details

#default_xbar_opts(options) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/xbar/association.rb', line 18

def default_xbar_opts(options)
  if options[:before_add].is_a?(Array)
    options[:before_add] << :set_connection_on_association
  elsif options[:before_add].is_a?(Symbol)
    options[:before_add] = [:set_connection_on_association, options[:before_add]]
  else
    options[:before_add] = :set_connection_on_association
  end

  if options[:before_remove].is_a?(Array)
    options[:before_remove] << :set_connection_on_association
  elsif options[:before_remove].is_a?(Symbol)
    options[:before_remove] = [:set_connection_on_association, options[:before_remove]]
  else
    options[:before_remove] = :set_connection_on_association
  end
end

#has_and_belongs_to_many(association_id, options = {}, &extension) ⇒ Object



13
14
15
16
# File 'lib/xbar/association.rb', line 13

def has_and_belongs_to_many(association_id, options = {}, &extension)
  default_xbar_opts(options)
  super
end

#has_many(association_id, options = {}, &extension) ⇒ Object



8
9
10
11
# File 'lib/xbar/association.rb', line 8

def has_many(association_id, options = {}, &extension)
  default_xbar_opts(options)
  super
end