class Luchadeer::Resource
Public Class Methods
find(id, refresh = false)
click to toggle source
# File lib/luchadeer/resource.rb, line 7 def find(id, refresh = false) Luchadeer.client.send(self::DETAIL, id, refresh) end
new(hash = nil)
click to toggle source
andreapavoni.com/blog/2013/4/create-recursive-openstruct-from-a-ruby-hash
# File lib/luchadeer/resource.rb, line 17 def initialize(hash = nil) @table = {} @hash_table = {} return unless hash hash.each do |k, v| @hash_table[k.to_sym] = v @table[k.to_sym] = deep_structify(k, v) new_ostruct_member(k) end end
search(query = nil, refresh = false)
click to toggle source
# File lib/luchadeer/resource.rb, line 11 def search(query = nil, refresh = false) Luchadeer.client.send(self::LIST, query, refresh) end
Public Instance Methods
detail()
click to toggle source
# File lib/luchadeer/resource.rb, line 34 def detail api_detail_url ? Luchadeer.client.fetch(api_detail_url, false, self.class) : self end
to_h()
click to toggle source
# File lib/luchadeer/resource.rb, line 30 def to_h @hash_table end
Private Instance Methods
deep_structify(k, v)
click to toggle source
# File lib/luchadeer/resource.rb, line 40 def deep_structify(k, v) case v when Hash then Luchadeer::Resource.new(v) when Array then v.map { |n| Luchadeer::Resource.new(n) } else v end end