class Velocity::Base

Attributes

resource_class_name[R]

Public Class Methods

create(args) click to toggle source
# File lib/velocity/base.rb, line 17
def self.create(args)
  data = resource_class.new(args).create
  new(data["attributes"].merge(id: data["id"]))
end
find_by(args) click to toggle source
# File lib/velocity/base.rb, line 28
def self.find_by(args)
  where(args).first
end
find_by!(args) click to toggle source
# File lib/velocity/base.rb, line 32
def self.find_by!(args)
  where(args).first or raise NotFoundError, "record not found with #{args.inspect}"
end
new(args) click to toggle source
Calls superclass method
# File lib/velocity/base.rb, line 13
def initialize(args)
  super(args.deep_transform_keys {|key| key.to_s.underscore })
end
resource_class(class_name = nil) click to toggle source
# File lib/velocity/base.rb, line 8
def resource_class(class_name = nil)
  @resource_class_name ||= class_name
end
where(args) click to toggle source
# File lib/velocity/base.rb, line 22
def self.where(args)
  resource_class.new(args).fetch.map do |data|
    new(data["attributes"].merge(id: data["id"]))
  end
end