module Mashery class RpcClient 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 Mashery.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 def self.object_type self.name.underscore.split('/').last.pluralize end end end end