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
Returns a new instance of Configuration.
23 24 25 |
# File 'lib/contentful_model.rb', line 23 def initialize @entry_mapping ||= {} end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
21 22 23 |
# File 'lib/contentful_model.rb', line 21 def access_token @access_token end |
#entry_mapping ⇒ Object
Returns the value of attribute entry_mapping.
21 22 23 |
# File 'lib/contentful_model.rb', line 21 def entry_mapping @entry_mapping end |
#space ⇒ Object
Returns the value of attribute space.
21 22 23 |
# File 'lib/contentful_model.rb', line 21 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
30 31 32 33 34 |
# File 'lib/contentful_model.rb', line 30 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.
39 40 41 |
# File 'lib/contentful_model.rb', line 39 def to_hash Hash[instance_variables.map { |name| [name.to_s.gsub("@","").to_sym, instance_variable_get(name)] } ] end |