Sha256: 044e8f29c741b27770c74e2b2f69f15fdb9731be30b89a4fbd8f299f959ee103
Contents?: true
Size: 951 Bytes
Versions: 1
Compression:
Stored size: 951 Bytes
Contents
module AbsorbApi class ResourceNotFound < StandardError; end class RouteNotFound < StandardError; end class ValidationError < StandardError; end module Orm extend ActiveSupport::Concern class_methods do def find(id) raise ResourceNotFound if id.blank? response = Base.api.get("#{to_s.demodulize.pluralize}/#{id}") if response.status == 404 raise(RouteNotFound) elsif response.status == 400 raise ResourceNotFound else new(response.body) end end def all response = Base.api.get("#{to_s.demodulize.pluralize}") if response.status == 404 raise RouteNotFound elsif response.status == 400 raise ResourceNotFound else Collection.new( response.body.map! do |attributes| new(attributes) end, {klass: to_s.demodulize } ) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
absorb_api-0.1.6 | lib/absorb_api/orm.rb |