Class: Jekyll::Client
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Jekyll::Client
- Defined in:
- lib/jekyll-fridge.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #before_method(method) ⇒ Object
- #collections ⇒ Object
- #content ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #settings ⇒ Object
- #types ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
55 56 57 58 59 60 61 |
# File 'lib/jekyll-fridge.rb', line 55 def initialize(config) @client = FridgeApi.client({ :client_id => config['client_id'], :client_secret => config['client_secret'] }) @config = config.delete_if { |k, v| k.to_s.match(/client/) } end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
53 54 55 |
# File 'lib/jekyll-fridge.rb', line 53 def client @client end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
53 54 55 |
# File 'lib/jekyll-fridge.rb', line 53 def config @config end |
Instance Method Details
#before_method(method) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/jekyll-fridge.rb', line 63 def before_method(method) # try content type type = @client.get("types/#{method}") if type && type.kind_of?(FridgeApi::Model) return Jekyll.stringify_keys_deep(type.attrs.merge({ 'content' => ContentDrop.new(@client, "content", "type=#{type.slug}") })) end # try user role role = @client.get("roles/#{method}") if role && role.kind_of?(FridgeApi::Model) return Jekyll.stringify_keys_deep(role.attrs.merge({ 'users' => ContentDrop.new(@client, "users", "role=#{role.slug}") })) end nil end |
#collections ⇒ Object
87 88 89 |
# File 'lib/jekyll-fridge.rb', line 87 def collections ContentDrop.new(@client, "collections") end |
#content ⇒ Object
83 84 85 |
# File 'lib/jekyll-fridge.rb', line 83 def content ContentDrop.new(@client, "content") end |
#settings ⇒ Object
91 92 93 |
# File 'lib/jekyll-fridge.rb', line 91 def settings ContentDrop.new(@client, "settings") end |
#types ⇒ Object
95 96 97 |
# File 'lib/jekyll-fridge.rb', line 95 def types ContentDrop.new(@client, "types") end |
#users ⇒ Object
99 100 101 |
# File 'lib/jekyll-fridge.rb', line 99 def users ContentDrop.new(@client, "users") end |