Class: ContentfulMiddleman::Instance
- Inherits:
-
Object
- Object
- ContentfulMiddleman::Instance
- Defined in:
- lib/contentful_middleman/instance.rb
Constant Summary collapse
- API_PREVIEW_URL =
'preview.contentful.com'
Instance Method Summary collapse
- #client ⇒ Object
- #content_types_ids_to_mappers ⇒ Object
- #content_types_ids_to_names ⇒ Object
- #entries ⇒ Object
-
#initialize(extension) ⇒ Instance
constructor
A new instance of Instance.
- #options ⇒ Object
- #space_name ⇒ Object
Constructor Details
#initialize(extension) ⇒ Instance
Returns a new instance of Instance.
5 6 7 |
# File 'lib/contentful_middleman/instance.rb', line 5 def initialize(extension) @extension = extension end |
Instance Method Details
#client ⇒ Object
41 42 43 |
# File 'lib/contentful_middleman/instance.rb', line 41 def client @client ||= Contentful::Client.new() end |
#content_types_ids_to_mappers ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/contentful_middleman/instance.rb', line 21 def content_types_ids_to_mappers @content_types_mappers ||= .content_types.reduce({}) do |acc, (content_type_id, config)| content_type_mapper = config.fetch(:mapper) acc[content_type_id] = content_type_mapper acc end end |
#content_types_ids_to_names ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/contentful_middleman/instance.rb', line 29 def content_types_ids_to_names @content_types_names ||= .content_types.reduce({}) do |acc, (content_type_id, config)| content_type_name = config.fetch(:name) acc[content_type_id] = content_type_name acc end end |
#entries ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/contentful_middleman/instance.rb', line 9 def entries if .all_entries all_entries(.cda_query) else client.entries(.cda_query) end end |
#options ⇒ Object
37 38 39 |
# File 'lib/contentful_middleman/instance.rb', line 37 def @extension. end |
#space_name ⇒ Object
17 18 19 |
# File 'lib/contentful_middleman/instance.rb', line 17 def space_name @space_name ||= .space.fetch(:name) end |