class SeekParty::SeekPartyEngine

Attributes

inspected_class[RW]
seek_party_attribute[RW]
seek_party_query[RW]

Public Class Methods

new(inspected_class, params: {}, white_list: nil, black_list: nil, scopes: {}) click to toggle source
# File lib/seek_party/seek_party_engine.rb, line 7
def initialize(inspected_class,
               params: {},
               white_list: nil,
               black_list: nil,
               scopes: {})
  @seek_party_attribute = SeekPartyAttribute.new(inspected_class,
                                                 white_list,
                                                 black_list)
  @seek_party_query = SeekPartyQueryBuilder.new(params)
  @inspected_class = inspected_class
  @scopes = scopes
end

Public Instance Methods

Private Instance Methods

scope_call(key, value) click to toggle source
# File lib/seek_party/seek_party_engine.rb, line 53
def scope_call(key, value)
  if value.present?
    @inspected_class = @inspected_class.method(key).call(*value)
  else
    @inspected_class = @inspected_class.method(key).call
  end
end
setup_scopes() click to toggle source
# File lib/seek_party/seek_party_engine.rb, line 36
def setup_scopes
  # Iterate trough the scopes that may have been
  # passed. PS: This is more of a luxury than anything
  # else, as the returned object from run_search is an
  # ActiveRecord_Relation object that would accept
  # method chaining
  @scopes.each do |scope|
    if scope.respond_to?(:keys)
      scope.keys.each do |key|
        scope_call(key, scope[key])
      end
    else
      scope_call(scope, nil)
    end
  end
end