class Feathr::Api::FeathrObject

Attributes

data[RW]
id[RW]

Public Class Methods

nested(*resources) click to toggle source
# File lib/feathr/api/feathr_object.rb, line 28
def self.nested(*resources)
  resources.each do |resource|
    define_method(resource) do
      ivar = "@#{ resource }"
      klass_name = resource.to_s.split('_').collect(&:capitalize).join
      klass = Object.const_get("Feathr::Api::#{ klass_name }")

      instance_variable_get(ivar) ||
      instance_variable_set(ivar, klass.new(prepended_path: path))
    end
  end
end
new(data, id) click to toggle source
Calls superclass method Feathr::Api::FeathrEndpoint::new
# File lib/feathr/api/feathr_object.rb, line 9
def initialize(data, id)
  @data = data
  @id   = id

  super()
end

Public Instance Methods

as_json() click to toggle source
# File lib/feathr/api/feathr_object.rb, line 24
def as_json
  data.to_h
end
full_path() click to toggle source
# File lib/feathr/api/feathr_object.rb, line 20
def full_path
  url = [client.config.base_url, path].join('/') + "/"
end
path() click to toggle source
# File lib/feathr/api/feathr_object.rb, line 16
def path
  [api_path, id].join('')
end