Class: Jekyll::Fridge::Client
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Jekyll::Fridge::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
- #get(path) ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #reset! ⇒ Object
- #settings ⇒ Object
- #types ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
63 64 65 66 67 68 69 70 |
# File 'lib/jekyll-fridge.rb', line 63 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(/secret/) || v.to_s.match(/sk/) } reset!() end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
61 62 63 |
# File 'lib/jekyll-fridge.rb', line 61 def client @client end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
61 62 63 |
# File 'lib/jekyll-fridge.rb', line 61 def config @config end |
Instance Method Details
#before_method(method) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/jekyll-fridge.rb', line 81 def before_method(method) # try content type type = get("types/#{method}") if type && type.kind_of?(FridgeApi::Model) return Jekyll::Fridge.stringify_keys_deep(type.attrs.merge({ 'content' => ContentDrop.new(self, "content", "type=#{type.slug}") })) end # try user role role = get("roles/#{method}") if role && role.kind_of?(FridgeApi::Model) return Jekyll::Fridge.stringify_keys_deep(role.attrs.merge({ 'users' => ContentDrop.new(self, "users", "role=#{role.slug}") })) end nil end |
#collections ⇒ Object
105 106 107 |
# File 'lib/jekyll-fridge.rb', line 105 def collections ContentDrop.new(self, "collections") end |
#content ⇒ Object
101 102 103 |
# File 'lib/jekyll-fridge.rb', line 101 def content ContentDrop.new(self, "content") end |
#get(path) ⇒ Object
72 73 74 75 |
# File 'lib/jekyll-fridge.rb', line 72 def get(path) return @cache[path] if @cache.has_key?(path) @cache[path] = @client.get(path) end |
#reset! ⇒ Object
77 78 79 |
# File 'lib/jekyll-fridge.rb', line 77 def reset! @cache = Hash.new end |
#settings ⇒ Object
109 110 111 |
# File 'lib/jekyll-fridge.rb', line 109 def settings ContentDrop.new(self, "settings") end |
#types ⇒ Object
113 114 115 |
# File 'lib/jekyll-fridge.rb', line 113 def types ContentDrop.new(self, "types") end |
#users ⇒ Object
117 118 119 |
# File 'lib/jekyll-fridge.rb', line 117 def users ContentDrop.new(self, "users") end |