Module: Octopus::Association
- Defined in:
- lib/octopus/association.rb
Defined Under Namespace
Modules: InstanceMethods
Class Method Summary collapse
Instance Method Summary collapse
- #default_octopus_opts(options) ⇒ Object
- #has_and_belongs_to_many(association_id, options = {}, &extension) ⇒ Object
- #has_many(association_id, options = {}, &extension) ⇒ Object
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
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/octopus/association.rb', line 51 def default_octopus_opts() if [:before_add].is_a?(Array) [:before_add] << :set_connection_on_association elsif [:before_add].is_a?(Symbol) [:before_add] = [:set_connection_on_association, [:before_add]] else [:before_add] = :set_connection_on_association end if [:before_remove].is_a?(Array) [:before_remove] << :set_connection_on_association elsif [:before_remove].is_a?(Symbol) [:before_remove] = [:set_connection_on_association, [:before_remove]] else [:before_remove] = :set_connection_on_association end end |
#has_and_belongs_to_many(association_id, options = {}, &extension) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/octopus/association.rb', line 36 def has_and_belongs_to_many(association_id, scope=nil, ={}, &extension) if == {} && scope.is_a?(Hash) default_octopus_opts(scope) else default_octopus_opts() end super end |
#has_many(association_id, options = {}, &extension) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/octopus/association.rb', line 19 def has_many(association_id, scope=nil, ={}, &extension) if == {} && scope.is_a?(Hash) default_octopus_opts(scope) else default_octopus_opts() end super end |