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.



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

def initialize
  @entry_mapping ||= {}
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#entry_mappingObject

Returns the value of attribute entry_mapping.



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

def entry_mapping
  @entry_mapping
end

#spaceObject

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

Parameters:

  • options (Hash)


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

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)


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