module Scalingo::Endpoint::ClassMethods

Public Instance Methods

resources(name, opts = {}) click to toggle source
# File lib/scalingo/endpoint.rb, line 10
def resources(name, opts = {})
  name = name.to_s

  endpoint_opts = { auth_api: opts[:auth_api] }

  define_method(name.pluralize.underscore) do
    Scalingo::Endpoint.const_get(
      name.pluralize.camelize,
    ).new(self, nil, endpoint_opts)
  end

  return if opts[:collection_only]

  define_method(name.singularize.underscore) do |id|
    send(name.pluralize.underscore).find(id)
  end
end