Module: Octopus::AssociationCollection
- Defined in:
- lib/octopus/association_collection.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build_with_octopus(*args, &block) ⇒ Object
- #count(*args) ⇒ Object
- #create_with_octopus(*args, &block) ⇒ Object
- #create_with_octopus!(*args, &block) ⇒ Object
- #ids_reader_with_octopus(*args) ⇒ Object
- #ids_writer_with_octopus(*args) ⇒ Object
- #reader_with_octopus(*args) ⇒ Object
- #should_wrap_the_connection? ⇒ Boolean
- #writer_with_octopus(*args) ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/octopus/association_collection.rb', line 3 def self.included(base) if Octopus.rails31? || Octopus.rails32? base.instance_eval do alias_method_chain :reader, :octopus alias_method_chain :writer, :octopus alias_method_chain :ids_reader, :octopus alias_method_chain :ids_writer, :octopus alias_method_chain :create, :octopus alias_method_chain :create!, :octopus alias_method_chain :build, :octopus end end end |
Instance Method Details
#build_with_octopus(*args, &block) ⇒ Object
17 18 19 20 |
# File 'lib/octopus/association_collection.rb', line 17 def build_with_octopus(*args, &block) owner.reload_connection build_without_octopus(*args, &block) end |
#count(*args) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/octopus/association_collection.rb', line 56 def count(*args) if should_wrap_the_connection? Octopus.using(@owner.current_shard) { super } else super end end |
#create_with_octopus(*args, &block) ⇒ Object
42 43 44 45 |
# File 'lib/octopus/association_collection.rb', line 42 def create_with_octopus(*args, &block) owner.reload_connection create_without_octopus(*args, &block) end |
#create_with_octopus!(*args, &block) ⇒ Object
47 48 49 50 |
# File 'lib/octopus/association_collection.rb', line 47 def create_with_octopus!(*args, &block) owner.reload_connection create_without_octopus!(*args, &block) end |
#ids_reader_with_octopus(*args) ⇒ Object
32 33 34 35 |
# File 'lib/octopus/association_collection.rb', line 32 def ids_reader_with_octopus(*args) owner.reload_connection ids_reader_without_octopus(*args) end |
#ids_writer_with_octopus(*args) ⇒ Object
37 38 39 40 |
# File 'lib/octopus/association_collection.rb', line 37 def ids_writer_with_octopus(*args) owner.reload_connection ids_writer_without_octopus(*args) end |
#reader_with_octopus(*args) ⇒ Object
22 23 24 25 |
# File 'lib/octopus/association_collection.rb', line 22 def reader_with_octopus(*args) owner.reload_connection reader_without_octopus(*args) end |
#should_wrap_the_connection? ⇒ Boolean
52 53 54 |
# File 'lib/octopus/association_collection.rb', line 52 def should_wrap_the_connection? @owner.respond_to?(:current_shard) && @owner.current_shard != nil end |
#writer_with_octopus(*args) ⇒ Object
27 28 29 30 |
# File 'lib/octopus/association_collection.rb', line 27 def writer_with_octopus(*args) owner.reload_connection writer_without_octopus(*args) end |