Sha256: 6790a0441bbf813895087d22fc0d62d2e7722dee38bdb347a4ff3bb65628b0e4
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
require 'active_support/inflector' module Aptible class Api::Resource < Api def self.basename name.split('::').last.downcase.pluralize end def self.collection_url config = Aptible::Api.configuration config.root_url.chomp('/') + "/#{basename}" end def self.all(options = {}) resource = new(options).find_by_url(collection_url) resource.send(basename).entries end def self.find(id) find_by_url("#{collection_url}/#{id}") end def self.find_by_url(url) # REVIEW: Should exception be raised if return type mismatch? new.find_by_url(url) rescue nil end # rubocop:disable PredicateName def self.has_many(relation) define_method relation do get unless loaded if (memoized = instance_variable_get("@#{relation}")) memoized elsif links[relation] instance_variable_set("@#{relation}", links[relation].entries) end end end # rubocop:enable PredicateName end end require 'aptible/api/account' require 'aptible/api/app' require 'aptible/api/attachment' require 'aptible/api/configuration' require 'aptible/api/container' require 'aptible/api/disk' require 'aptible/api/image' require 'aptible/api/operation' require 'aptible/api/permission' require 'aptible/api/proxy' require 'aptible/api/release' require 'aptible/api/service' require 'aptible/api/vhost'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aptible-api-0.2.1 | lib/aptible/api/resource.rb |