Class: Targetmy::Config
- Inherits:
-
Object
- Object
- Targetmy::Config
- Defined in:
- lib/targetmy/config.rb,
lib/targetmy/config/site.rb,
lib/targetmy/config/site/mobile.rb,
lib/targetmy/config/site/teaser.rb
Defined Under Namespace
Classes: Site
Constant Summary collapse
- SUPPORTED_ADV_TYPES =
[:site]
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Instance Method Summary collapse
-
#initialize(config) ⇒ Config
constructor
A new instance of Config.
- #parse(config) ⇒ Object
Constructor Details
#initialize(config) ⇒ Config
Returns a new instance of Config.
10 11 12 13 14 |
# File 'lib/targetmy/config.rb', line 10 def initialize(config) @items = [] parse config end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
6 7 8 |
# File 'lib/targetmy/config.rb', line 6 def items @items end |
Instance Method Details
#parse(config) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# 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 |