Sha256: 95c443581e24ee1364a4cd245e1be56ab0f9236d6f3f2d401d410bab8d225772

Contents?: true

Size: 924 Bytes

Versions: 4

Compression:

Stored size: 924 Bytes

Contents

module Masheri
  class RestClient
    class Base
      def initialize(attributes)
        attributes.each do |key, value|
          send("#{key}=", value)
        end
      end

      def self.count
        default_query.items(1).to_json["result"]["total_items"]
      end

      def self.all
        default_query.all
      end

      def self.items(argument)
        default_query.items(argument)
      end

      def self.where(argument)
        default_query.where(argument)
      end

      def self.page(argument)
        default_query.page(argument)
      end

      def self.find_each(&block)
        default_query.find_each(&block)
      end

      def self.standard_query
        Masheri.rpc.query_builder(self).from(object_type).items(100)
      end

      def self.default_query
        standard_query
      end

      def self.first
        new(standard_query.items(1).all.items[0])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
masheri-0.4.0 lib/masheri/rest_client/base.rb
masheri-0.3.10 lib/masheri/rest_client/base.rb
masheri-0.3.8 lib/masheri/rest_client/base.rb
masheri-0.3.7 lib/masheri/rest_client/base.rb