Class: ActiveRecord::ShardFor::STIShardRepository
- Inherits:
-
AbstractShardRepository
- Object
- AbstractShardRepository
- ActiveRecord::ShardFor::STIShardRepository
- Defined in:
- lib/activerecord/shard_for/sti_shard_repository.rb
Instance Attribute Summary collapse
-
#inherited_class ⇒ Object
readonly
Returns the value of attribute inherited_class.
Attributes inherited from AbstractShardRepository
Instance Method Summary collapse
-
#initialize(inherited_class, base_shards) ⇒ STIShardRepository
constructor
A new instance of STIShardRepository.
Methods inherited from AbstractShardRepository
Constructor Details
#initialize(inherited_class, base_shards) ⇒ STIShardRepository
Returns a new instance of STIShardRepository.
8 9 10 11 12 13 14 15 16 |
# File 'lib/activerecord/shard_for/sti_shard_repository.rb', line 8 def initialize(inherited_class, base_shards) @inherited_class = inherited_class @shards = base_shards.each_with_object({}) do |(connection_name, base_model), hash| model = generate_model_from_shard(connection_name, base_model) inherited_class.const_set(:"#{generate_shard_name(connection_name)}", model) hash[connection_name] = model end end |
Instance Attribute Details
#inherited_class ⇒ Object (readonly)
Returns the value of attribute inherited_class.
4 5 6 |
# File 'lib/activerecord/shard_for/sti_shard_repository.rb', line 4 def inherited_class @inherited_class end |