Class: SmartCollection::Mixin
- Inherits:
-
Module
- Object
- Module
- SmartCollection::Mixin
- Defined in:
- lib/smart_collection/mixin.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #included(base) ⇒ Object
-
#initialize(raw_config) ⇒ Mixin
constructor
A new instance of Mixin.
Constructor Details
#initialize(raw_config) ⇒ Mixin
Returns a new instance of Mixin.
31 32 33 |
# File 'lib/smart_collection/mixin.rb', line 31 def initialize raw_config @raw_config = raw_config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
29 30 31 |
# File 'lib/smart_collection/mixin.rb', line 29 def config @config end |
Instance Method Details
#included(base) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/smart_collection/mixin.rb', line 35 def included base @config = config = SmartCollection::Config.new(@raw_config) = {smart_collection: config} if config.item_class_name [:class_name] = config.item_class_name end reflection = Builder::SmartCollectionAssociation.build(base, config.items_name, nil, ) ::ActiveRecord::Reflection.add_reflection base, config.items_name, reflection base.include(InstanceMethods) base.extend(ClassMethods) if cache_class = CacheManager.determine_class(@raw_config) config.cache_manager = cache_class.new(model: base, config: config) end end |