Module: Gimlet::Queryable::API

Extended by:
Forwardable
Included in:
Model::ClassMethods
Defined in:
lib/gimlet/queryable.rb

Instance Method Summary collapse

Instance Method Details

#new_queryObject



18
19
20
# File 'lib/gimlet/queryable.rb', line 18

def new_query
  current_scope || Query.new(self)
end

#select(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/gimlet/queryable.rb', line 8

def select(options = {})
  selecting = @instances
  options[:where].each do |attribute, operator, argument|
    selecting = selecting.select do |id, instance|
      instance[attribute].send(operator, argument)
    end
  end
  selecting.values
end