class Helium::Metadata
TODO make Metadata
inherit from Resource
and implement method_missing
for all resources to automatically generate methods for attributes rather than whitelisting them with hardcoding
Public Class Methods
new(opts = {})
click to toggle source
# File lib/helium/metadata.rb, line 6 def initialize(opts = {}) @client = opts.fetch(:client) @klass = opts.fetch(:klass) @params = fetch_params end
Public Instance Methods
id()
click to toggle source
# File lib/helium/metadata.rb, line 13 def id @klass.id end
inspect()
click to toggle source
# File lib/helium/metadata.rb, line 21 def inspect "<Helium::Metadata properties=#{properties}>" end
method_missing(method_name, *arguments, &block)
click to toggle source
Calls superclass method
# File lib/helium/metadata.rb, line 25 def method_missing(method_name, *arguments, &block) properties[method_name.to_s] || super end
properties()
click to toggle source
# File lib/helium/metadata.rb, line 17 def properties @params["attributes"] end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/helium/metadata.rb, line 29 def respond_to_missing?(method_name, include_private = false) properties[method_name.to_s] || super end
update(attributes = {})
click to toggle source
# File lib/helium/metadata.rb, line 33 def update(attributes = {}) body = { data: { attributes: attributes, id: id, type: "metadata" } } response = @client.patch(path, body: body) @params = JSON.parse(response.body)["data"] return self end
Protected Instance Methods
fetch_params()
click to toggle source
# File lib/helium/metadata.rb, line 53 def fetch_params response = @client.get(path) JSON.parse(response.body)["data"] end
path()
click to toggle source
# File lib/helium/metadata.rb, line 49 def path "#{@klass.resource_path}/metadata" end