Class: ContentfulModel::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/contentful_model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



24
25
26
# File 'lib/contentful_model.rb', line 24

def initialize
  @entry_mapping ||= {}
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



22
23
24
# File 'lib/contentful_model.rb', line 22

def access_token
  @access_token
end

#entry_mappingObject

Returns the value of attribute entry_mapping.



22
23
24
# File 'lib/contentful_model.rb', line 22

def entry_mapping
  @entry_mapping
end

#spaceObject

Returns the value of attribute space.



22
23
24
# File 'lib/contentful_model.rb', line 22

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

Parameters:

  • options (Hash)


31
32
33
34
35
# File 'lib/contentful_model.rb', line 31

def options=(options)
  options.each do |k,v|
    instance_variable_set(:"@#{k}",v)
  end
end

#to_hashHash

Return the Configuration object as a hash, with symbols as keys.

Returns:

  • (Hash)


40
41
42
# File 'lib/contentful_model.rb', line 40

def to_hash
  Hash[instance_variables.map { |name| [name.to_s.gsub("@","").to_sym, instance_variable_get(name)] } ]
end