class Targetmy::Config

Constants

SUPPORTED_ADV_TYPES

Attributes

items[R]

Public Class Methods

new(config) click to toggle source
# File lib/targetmy/config.rb, line 10
def initialize(config)
  @items = []

  parse config
end

Public Instance Methods

parse(config) click to toggle source
# File lib/targetmy/config.rb, line 16
def parse(config)
  config = config.is_a?(Hash) ? [config] : config
  config.each do |cnf|
    if SUPPORTED_ADV_TYPES.include? cnf[:type].to_sym
      type = cnf[:type].to_s.capitalize
      klass = Object.const_get("Targetmy::Config::#{type}")
      @items << klass.new(cnf)
    else
      raise Targetmy::UnsupportedKey.new(cnf[:type].to_sym)
    end
  end
end