Class: ContentfulModel::Configuration

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

Overview

Configuration store for ContentfulModel

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



35
36
37
38
39
40
# File 'lib/contentful_model.rb', line 35

def initialize
  @entry_mapping ||= {}
  @environment = 'master'
  @integration_name = 'contentful_model'
  @integration_version = ::ContentfulModel::VERSION
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



27
28
29
# File 'lib/contentful_model.rb', line 27

def access_token
  @access_token
end

#default_localeObject

Returns the value of attribute default_locale.



27
28
29
# File 'lib/contentful_model.rb', line 27

def default_locale
  @default_locale
end

#entry_mappingObject

Returns the value of attribute entry_mapping.



27
28
29
# File 'lib/contentful_model.rb', line 27

def entry_mapping
  @entry_mapping
end

#environmentObject

Returns the value of attribute environment.



27
28
29
# File 'lib/contentful_model.rb', line 27

def environment
  @environment
end

#management_tokenObject

Returns the value of attribute management_token.



27
28
29
# File 'lib/contentful_model.rb', line 27

def management_token
  @management_token
end

#preview_access_tokenObject

Returns the value of attribute preview_access_token.



27
28
29
# File 'lib/contentful_model.rb', line 27

def preview_access_token
  @preview_access_token
end

#spaceObject

Returns the value of attribute space.



27
28
29
# File 'lib/contentful_model.rb', line 27

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)


45
46
47
48
49
# File 'lib/contentful_model.rb', line 45

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)


53
54
55
# File 'lib/contentful_model.rb', line 53

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