Sha256: bf47c7d87aac74f53beed3e1c0c69dc18785d1319bfcd14f69bdb38206457550

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

# -*- encoding : utf-8 -*-
module RademadeAdmin
  module Model
    module Adapter
      class Query

        def initialize(model)
          @model = model
        end

        def find(ids)
          @model.find(ids)
        end

        #
        # @param search_conditions [RademadeAdmin::Search::Conditions::Abstract]
        #
        def exec_query(search_conditions)
          @result = search_conditions.base_condition(@model)

          return nil if @result.nil?

          search_conditions.conditions.each do |query_part, values|
            @result = self.send(query_part, values) unless values.nil?
          end

          @result
        end

        protected

        def where(where_conditions)
          @result
        end

        def order(order_conditions)
          @result
        end

        def page(page_condition)
          @result.page(page_condition)
        end

        def per_page(per_page_condition)
          @result.per(per_page_condition)
        end

        def limit(limit_condition)
          @result.limit(limit_condition)
        end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rademade_admin-0.2.2 lib/rademade_admin/model/adapter/query.rb
rademade_admin-0.2.1 lib/rademade_admin/model/adapter/query.rb
rademade_admin-0.2.0 lib/rademade_admin/model/adapter/query.rb
rademade_admin-0.1.6 lib/rademade_admin/model/adapter/query.rb
rademade_admin-0.1.5 lib/rademade_admin/model/adapter/query.rb
rademade_admin-0.1.4 lib/rademade_admin/model/adapter/query.rb
rademade_admin-0.1.3 lib/rademade_admin/model/adapter/query.rb
rademade_admin-0.1.2 lib/rademade_admin/model/adapter/query.rb
rademade_admin-0.1.1 lib/rademade_admin/model/adapter/query.rb
rademade_admin-0.1.0 lib/rademade_admin/model/adapter/query.rb