Class: MrMongo::Dsl

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Dsl

Returns a new instance of Dsl.



5
6
7
8
9
# File 'lib/mr_mongo/dsl.rb', line 5

def initialize(context)
  @context        = context
  @map_reduce     = MapReduce.new(context)
  @default_params = {}
end

Instance Attribute Details

#map_reduceObject (readonly)

Returns the value of attribute map_reduce.



3
4
5
# File 'lib/mr_mongo/dsl.rb', line 3

def map_reduce
  @map_reduce
end

Instance Method Details

#default_param(key, value) ⇒ Object



29
30
31
# File 'lib/mr_mongo/dsl.rb', line 29

def default_param(key, value)
  @default_params[key] = value
end

#paramsObject



21
22
23
24
25
26
27
# File 'lib/mr_mongo/dsl.rb', line 21

def params
  if @context.params?
    @default_params.merge(@context.params)
  else
    @default_params
  end
end

#parse(&block) ⇒ Object



11
12
13
14
15
# File 'lib/mr_mongo/dsl.rb', line 11

def parse(&block)
  instance_eval &block
  
  self
end

#set(key, value = true) ⇒ Object



17
18
19
# File 'lib/mr_mongo/dsl.rb', line 17

def set(key, value = true)
  @map_reduce.send("#{key}=", value)
end