class Appilf::AppilfObject

Attributes

item_data[RW]
meta[RW]

Public Class Methods

new(api_element_hash) click to toggle source
# File lib/appilf/appilf_object.rb, line 21
def initialize(api_element_hash)
  init_meta_data(api_element_hash)
  self.item_data = api_element_hash.fetch('data', {}).methodize!
end

Public Instance Methods

add_relationships(relationships_hash) click to toggle source
# File lib/appilf/appilf_object.rb, line 41
def add_relationships(relationships_hash)
  return unless relationships_hash
  self.class.instance_eval do
    relationships_hash.each_pair do |k, v|
      define_method(k) { Util.translate_from_response(v) }
    end
  end
end
init_meta_data(api_element_hash) click to toggle source
# File lib/appilf/appilf_object.rb, line 26
def init_meta_data(api_element_hash)
  self.meta = api_element_hash.fetch('data', {}).delete('meta')
  self.links = api_element_hash.fetch('data', {}).delete('links')
  self.meta.methodize!
  self.links.methodize!
end
method_missing(method_name, *args) click to toggle source
# File lib/appilf/appilf_object.rb, line 37
def method_missing(method_name, *args)
  item_data.send(method_name)
end
respond_to_missing?(method_name, include_private = false) click to toggle source
# File lib/appilf/appilf_object.rb, line 33
def respond_to_missing?(method_name, include_private = false)
  item_data.keys.include? method_name
end