class Toshi::ApiResource
Public Class Methods
client()
click to toggle source
# File lib/toshi/api_resource.rb, line 13 def client Toshi::Client end
create_many(collection)
click to toggle source
# File lib/toshi/api_resource.rb, line 9 def create_many(collection) collection.map { |attr| self.new(attr) } end
create_one(attributes)
click to toggle source
# File lib/toshi/api_resource.rb, line 5 def create_one(attributes) self.new(attributes) end
new(attributes = {})
click to toggle source
# File lib/toshi/api_resource.rb, line 18 def initialize(attributes = {}) from_hash(attributes) end
Public Instance Methods
client()
click to toggle source
# File lib/toshi/api_resource.rb, line 31 def client Toshi::Client end
from_hash(attributes)
click to toggle source
# File lib/toshi/api_resource.rb, line 22 def from_hash(attributes) attributes.each do |key, val| instance_variable_set("@#{key}", val) self.class.send(:define_method, key) do instance_variable_get "@#{key}" end end end