Class: Brandmaker::VariableConfig
- Inherits:
-
Object
- Object
- Brandmaker::VariableConfig
- Defined in:
- lib/brandmaker/variable_config.rb
Constant Summary collapse
- VARIABLE_TYPES =
{ :"" => Variable, :media => MediaVariable, :external_media => ExternalMediaVariable, :grid => GridVariable }
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#label ⇒ Object
Returns the value of attribute label.
-
#name ⇒ Object
Returns the value of attribute name.
-
#purpose ⇒ Object
Returns the value of attribute purpose.
Instance Method Summary collapse
-
#initialize(*h) ⇒ VariableConfig
constructor
A new instance of VariableConfig.
- #to_typed_instance(data) ⇒ Object
Constructor Details
#initialize(*h) ⇒ VariableConfig
Returns a new instance of VariableConfig.
20 21 22 23 24 |
# File 'lib/brandmaker/variable_config.rb', line 20 def initialize(*h) if h.length == 1 && h.first.kind_of?(Hash) h.first.each { |k,v| send("#{k}=",v) } end end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
10 11 12 |
# File 'lib/brandmaker/variable_config.rb', line 10 def content_type @content_type end |
#label ⇒ Object
Returns the value of attribute label.
9 10 11 |
# File 'lib/brandmaker/variable_config.rb', line 9 def label @label end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/brandmaker/variable_config.rb', line 7 def name @name end |
#purpose ⇒ Object
Returns the value of attribute purpose.
11 12 13 |
# File 'lib/brandmaker/variable_config.rb', line 11 def purpose @purpose end |
Instance Method Details
#to_typed_instance(data) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/brandmaker/variable_config.rb', line 26 def to_typed_instance(data) type = content_type klass = VARIABLE_TYPES[content_type.to_s.downcase.to_sym] unless klass.nil? instance = klass.new(data) instance.config = self instance else raise "Unknown variable type #{type}" end end |