Module: Octoball::ShardedCollectionProxyCreate
- Included in:
- Octoball
- Defined in:
- lib/octoball/association.rb
Instance Method Summary collapse
Instance Method Details
#create(klass, association) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/octoball/association.rb', line 36 def create(klass, association) shard = association.owner.current_shard return super unless shard return RelationProxy.new(super, shard) if shard == ActiveRecord::Base.current_shard ret = nil ActiveRecord::Base.connected_to(shard: shard, role: Octoball.current_role) do ret = RelationProxy.new(super, shard) nil # return nil to avoid loading relation end ret end |