Class: ContentfulMiddleman::Mapper::Base
- Inherits:
-
Object
- Object
- ContentfulMiddleman::Mapper::Base
- Defined in:
- lib/contentful_middleman/mappers/base.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
-
#initialize(entries, options) ⇒ Base
constructor
A new instance of Base.
- #map(context, entry) ⇒ Object
Constructor Details
#initialize(entries, options) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 15 |
# File 'lib/contentful_middleman/mappers/base.rb', line 8 def initialize(entries, ) @entries = entries @options = @children = {} @created_at_key = using_camel_case? ? :createdAt : :created_at @updated_at_key = using_camel_case? ? :updatedAt : :updated_at @content_type_key = using_camel_case? ? :contentType : :content_type end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
6 7 8 |
# File 'lib/contentful_middleman/mappers/base.rb', line 6 def entries @entries end |
Instance Method Details
#map(context, entry) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/contentful_middleman/mappers/base.rb', line 17 def map(context, entry) @children = { :queue => [{ :context => context, :entry => entry }], :discovered => [entry.id] } while !@children[:queue].first.nil? do nxt = @children[:queue].pop context = nxt[:context] entry = nxt[:entry] map_entry_full(entry, context) end end |