Class: Mongery::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/mongery.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, engine = ActiveRecord::Base, schema = nil) ⇒ Builder

Returns a new instance of Builder.



10
11
12
13
14
15
16
# 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

Instance Attribute Details

#custom_operatorsObject

Returns the value of attribute custom_operators.



8
9
10
# File 'lib/mongery.rb', line 8

def custom_operators
  @custom_operators
end

#mapped_propertiesObject

Returns the value of attribute mapped_properties.



7
8
9
# File 'lib/mongery.rb', line 7

def mapped_properties
  @mapped_properties
end

#modelObject (readonly)

Returns the value of attribute model.



7
8
9
# File 'lib/mongery.rb', line 7

def model
  @model
end

#schemaObject (readonly)

Returns the value of attribute schema.



7
8
9
# File 'lib/mongery.rb', line 7

def schema
  @schema
end

#tableObject (readonly)

Returns the value of attribute table.



7
8
9
# File 'lib/mongery.rb', line 7

def table
  @table
end

Instance Method Details

#count(*args) ⇒ Object



31
32
33
# File 'lib/mongery.rb', line 31

def count(*args)
  build_query.where(*args).count
end

#find(*args) ⇒ Object



27
28
29
# File 'lib/mongery.rb', line 27

def find(*args)
  build_query.where(*args)
end

#index(*args) ⇒ Object



39
40
41
# File 'lib/mongery.rb', line 39

def index(*args)
  build_query.index(*args)
end

#insert(*args) ⇒ Object



35
36
37
# File 'lib/mongery.rb', line 35

def insert(*args)
  build_query.insert(*args)
end