Class: ContentfulModel::Configuration
- Inherits:
-
Object
- Object
- ContentfulModel::Configuration
- Defined in:
- lib/contentful_model.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#entry_mapping ⇒ Object
Returns the value of attribute entry_mapping.
-
#space ⇒ Object
Returns the value of attribute space.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#options=(options) ⇒ Object
Rather than listing out all the possible attributes as setters, we have a catchall called ‘options’ which takes a hash and generates instance vars.
-
#to_hash ⇒ Hash
Return the Configuration object as a hash, with symbols as keys.
Constructor Details
#initialize ⇒ Configuration
22 23 24 |
# File 'lib/contentful_model.rb', line 22 def initialize @entry_mapping ||= {} end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
20 21 22 |
# File 'lib/contentful_model.rb', line 20 def access_token @access_token end |
#entry_mapping ⇒ Object
Returns the value of attribute entry_mapping.
20 21 22 |
# File 'lib/contentful_model.rb', line 20 def entry_mapping @entry_mapping end |
#space ⇒ Object
Returns the value of attribute space.
20 21 22 |
# File 'lib/contentful_model.rb', line 20 def space @space end |
Instance Method Details
#options=(options) ⇒ Object
Rather than listing out all the possible attributes as setters, we have a catchall called ‘options’ which takes a hash and generates instance vars
29 30 31 32 33 |
# File 'lib/contentful_model.rb', line 29 def () .each do |k,v| instance_variable_set(:"@#{k}",v) end end |
#to_hash ⇒ Hash
Return the Configuration object as a hash, with symbols as keys.
38 39 40 |
# File 'lib/contentful_model.rb', line 38 def to_hash Hash[instance_variables.map { |name| [name.to_s.gsub("@","").to_sym, instance_variable_get(name)] } ] end |