class Mongery::Builder

Attributes

custom_operators[RW]
mapped_properties[R]
model[R]
schema[R]
table[R]

Public Class Methods

new(model, engine = ActiveRecord::Base, schema = nil) click to toggle source
# File lib/mongery.rb, line 10
def initialize(model, engine = ActiveRecord::Base, schema = nil)
  @model = model
  @table = Arel::Table.new(model, engine)
  @schema = Schema.new(schema) if schema
  @mapped_properties = {}
  @custom_operators = {}
end

Public Instance Methods

count(*args) click to toggle source
# File lib/mongery.rb, line 31
def count(*args)
  build_query.where(*args).count
end
find(*args) click to toggle source
# File lib/mongery.rb, line 27
def find(*args)
  build_query.where(*args)
end
index(*args) click to toggle source
# File lib/mongery.rb, line 39
def index(*args)
  build_query.index(*args)
end
insert(*args) click to toggle source
# File lib/mongery.rb, line 35
def insert(*args)
  build_query.insert(*args)
end
mapped_properties=(value) click to toggle source
# File lib/mongery.rb, line 18
def mapped_properties=(value)
  case value
  when Array
    @mapped_properties = Hash[ value.map { |v| [v.to_s, v] } ]
  else
    @mapped_properties = value
  end
end

Private Instance Methods

build_query() click to toggle source
# File lib/mongery.rb, line 45
def build_query
  Query.new(table, schema, mapped_properties, custom_operators)
end