Sha256: b8da07d8970e7d0bd1068718c8d70780f8ee803a9fba8a0b724a7c62ef3b6698

Contents?: true

Size: 1007 Bytes

Versions: 4

Compression:

Stored size: 1007 Bytes

Contents

module Loquor
  class Resource

    def initialize(data)
      @data = ObjectHash.new(data, strict: true)
    end

    def method_missing(name, *args)
      @data[name]
    rescue
      raise NameError.new("undefined local variable or method '#{name}' for #{self.class.name}")
    end

    def self.path=(path)
      @path = path
    end

    def self.path
      @path
    end

    def self.cache=(value)
      @value = value
    end

    def self.cache
      @value
    end

    def self.find(id)
      ApiCall::Show.new(self, id).execute
    end

    def self.find_each(&block)
      ApiCall::Index.new(self).find_each(&block)
    end

    def self.select(*args)
      ApiCall::Index.new(self).select(*args)
    end

    def self.where(*args)
      ApiCall::Index.new(self).where(*args)
    end

    def self.create(payload)
      ApiCall::Create.new(self, payload: payload).execute
    end

    def self.update(id, payload)
      ApiCall::Update.new(self, id, payload: payload).execute
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
loquor-1.0.0 lib/loquor/resource.rb
loquor-0.9.0 lib/loquor/resource.rb
loquor-0.8.0 lib/loquor/resource.rb
loquor-0.7.0 lib/loquor/resource.rb