Class: Jekyll::Fridge::ContentDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Jekyll::Fridge::ContentDrop
- Includes:
- Enumerable
- Defined in:
- lib/jekyll-fridge.rb
Instance Method Summary collapse
- #before_method(method) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(client, base, query = "", data = nil) ⇒ ContentDrop
constructor
A new instance of ContentDrop.
Constructor Details
#initialize(client, base, query = "", data = nil) ⇒ ContentDrop
Returns a new instance of ContentDrop.
126 127 128 129 130 131 |
# File 'lib/jekyll-fridge.rb', line 126 def initialize(client, base, query = "", data = nil) @client = client @base = base @query = query @data = data end |
Instance Method Details
#before_method(method) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/jekyll-fridge.rb', line 133 def before_method(method) # check for single content item item = @client.get("#{@base}/#{method}?#{@query}") return Model.new(item) if item && item.kind_of?(FridgeApi::Model) # filter by content type if @base == "content" && @query.empty? types = @client.get("#{@base}?type=#{method}") return ContentDrop.new(@client, @base, "type=#{method}", types) if types end # filter by user role if @base == "users" && @query.empty? roles = @client.get("#{@base}?role=#{method}") return ContentDrop.new(@client, @base, "role=#{method}", roles) if roles end nil end |