Class: SolidusFriendlyPromotions::NestedClassSet

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ NestedClassSet

Returns a new instance of NestedClassSet.



9
10
11
12
13
14
15
16
17
18
# File 'lib/solidus_friendly_promotions/nested_class_set.rb', line 9

def initialize(hash = {})
  @klass_sets = hash.map do |key, value|
    [
      key,
      Spree::Core::ClassConstantizer::Set.new.tap do |set|
        value.each { |klass_name| set << klass_name }
      end
    ]
  end.to_h
end

Instance Attribute Details

#klass_setsObject (readonly)

Returns the value of attribute klass_sets.



7
8
9
# File 'lib/solidus_friendly_promotions/nested_class_set.rb', line 7

def klass_sets
  @klass_sets
end

Instance Method Details

#[](klass) ⇒ Object



20
21
22
# File 'lib/solidus_friendly_promotions/nested_class_set.rb', line 20

def [](klass)
  klass_sets[klass.name]
end