Sha256: 80c2e015207c24289b8852ac41a7f6fdd1ae0e9625143f138bf0306a38a41aea
Contents?: true
Size: 904 Bytes
Versions: 1
Compression:
Stored size: 904 Bytes
Contents
module JsonApiClient module Legacy class QueryBuilder attr_reader :klass, :params def initialize(klass) @klass = klass @params = {} end def where(conditions = {}) @params.merge!(conditions) self end alias paginate where def order(conditions) where(order: conditions) end def includes(*tables) @params[:includes] ||= [] @params[:includes] += tables.flatten self end def page(number) where(page: number) end def first paginate(page: 1, per_page: 1).to_a.first end def build klass.new(params) end def to_a @to_a ||= klass.find(params) end alias all to_a def method_missing(method_name, *args, &block) to_a.send(method_name, *args, &block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
json_api_client-legacy-1.0.0.beta | lib/json_api_client/legacy/query_builder.rb |