Module: Octopus::Association

Defined in:
lib/octopus/association.rb

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



2
3
4
# File 'lib/octopus/association.rb', line 2

def self.extended(base)
  base.send(:include, InstanceMethods)
end

Instance Method Details

#default_octopus_opts(options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/octopus/association.rb', line 28

def default_octopus_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



23
24
25
26
# File 'lib/octopus/association.rb', line 23

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

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



18
19
20
21
# File 'lib/octopus/association.rb', line 18

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