Class: Spree::Core::NestedClassSet
- Inherits:
-
Object
- Object
- Spree::Core::NestedClassSet
- Defined in:
- lib/spree/core/nested_class_set.rb
Instance Attribute Summary collapse
-
#klass_sets ⇒ Object
readonly
Returns the value of attribute klass_sets.
Instance Method Summary collapse
- #[](klass) ⇒ Object
- #[]=(klass, klasses) ⇒ Object
-
#initialize(hash = {}) ⇒ NestedClassSet
constructor
A new instance of NestedClassSet.
Constructor Details
#initialize(hash = {}) ⇒ NestedClassSet
Returns a new instance of NestedClassSet.
10 11 12 13 14 15 16 17 |
# File 'lib/spree/core/nested_class_set.rb', line 10 def initialize(hash = {}) @klass_sets = hash.map do |key, value| [ key.to_s, ClassConstantizer::Set.new(default: value) ] end.to_h end |
Instance Attribute Details
#klass_sets ⇒ Object (readonly)
Returns the value of attribute klass_sets.
8 9 10 |
# File 'lib/spree/core/nested_class_set.rb', line 8 def klass_sets @klass_sets end |
Instance Method Details
#[](klass) ⇒ Object
19 20 21 |
# File 'lib/spree/core/nested_class_set.rb', line 19 def [](klass) klass_sets[klass.to_s] || [] end |
#[]=(klass, klasses) ⇒ Object
23 24 25 |
# File 'lib/spree/core/nested_class_set.rb', line 23 def []=(klass, klasses) klass_sets[klass.to_s] = ClassConstantizer::Set.new(default: klasses.map(&:to_s)) end |