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



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

def initialize
  @entry_mapping ||= {}
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#entry_mappingObject

Returns the value of attribute entry_mapping.



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

def entry_mapping
  @entry_mapping
end

#spaceObject

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 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.



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