class Noticent::Definitions::ProductGroup

Attributes

products[R]

Public Class Methods

new(config) click to toggle source
# File lib/noticent/definitions/product_group.rb, line 9
def initialize(config)
  @config = config
  @products = {}
end

Public Instance Methods

count() click to toggle source
# File lib/noticent/definitions/product_group.rb, line 30
def count
  @products.count
end
keys() click to toggle source
# File lib/noticent/definitions/product_group.rb, line 34
def keys
  @products.keys
end
not_to(name) click to toggle source
# File lib/noticent/definitions/product_group.rb, line 22
def not_to(name)
  raise BadConfiguration, 'product name should be a symbol' unless name.is_a? Symbol
  raise BadConfiguration, "product #{name} is not defined. Use products to define it first" unless @config.products[name]

  # include all products, except the one named
  @config.products.each { |k, v| @products[k] = v unless k == name }
end
to(name) click to toggle source
# File lib/noticent/definitions/product_group.rb, line 14
def to(name)
  raise BadConfiguration, 'product name should be a symbol' unless name.is_a? Symbol
  raise BadConfiguration, "product #{name} is already in the list" if @products[name]
  raise BadConfiguration, "product #{name} is not defined. Use products to define it first" unless @config.products[name]

  @products[name] = @config.products[name]
end
values() click to toggle source
# File lib/noticent/definitions/product_group.rb, line 38
def values
  @products.values
end