Class: Spree::Core::NestedClassSet

Inherits:
Object
  • Object
show all
Defined in:
lib/spree/core/nested_class_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_setsObject (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