Class: Jekyll::Strapi::StrapiDocumentDrop

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
lib/jekyll/strapi/drops.rb

Overview

Strapi Document access in Liquid

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ StrapiDocumentDrop

Returns a new instance of StrapiDocumentDrop.



7
8
9
# File 'lib/jekyll/strapi/drops.rb', line 7

def initialize(document)
  @document = document
end

Instance Attribute Details

#documentObject

Returns the value of attribute document.



5
6
7
# File 'lib/jekyll/strapi/drops.rb', line 5

def document
  @document
end

Instance Method Details

#[](attribute) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jekyll/strapi/drops.rb', line 11

def [](attribute)
  value = @document[attribute]

  case value
  when OpenStruct
    StrapiDocumentDrop.new(value)
  when Array
    StrapiCollectionDrop.new(value)
  else
    value
  end
end