Class: CouchView::Proxy

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/couch_view/proxy.rb

Direct Known Subclasses

Count::Proxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, map) ⇒ Proxy

Returns a new instance of Proxy.



25
26
27
28
29
30
# File 'lib/couch_view/proxy.rb', line 25

def initialize(model, map)
  @_model         = model
  @_map           = map
  @_conditions    = []
  @_query_options = default_query_options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(condition, *args, &block) ⇒ Object



42
43
44
45
46
# File 'lib/couch_view/proxy.rb', line 42

def method_missing(condition, *args, &block)
  condition = remove_exclamation(condition)
  @_conditions << condition
  self
end

Instance Attribute Details

#_mapObject (readonly)

Returns the value of attribute _map.



5
6
7
# File 'lib/couch_view/proxy.rb', line 5

def _map
  @_map
end

#_modelObject (readonly)

Returns the value of attribute _model.



5
6
7
# File 'lib/couch_view/proxy.rb', line 5

def _model
  @_model
end

#_query_optionsObject

Returns the value of attribute _query_options.



6
7
8
# File 'lib/couch_view/proxy.rb', line 6

def _query_options
  @_query_options
end

Instance Method Details

#_optionsObject



32
33
34
# File 'lib/couch_view/proxy.rb', line 32

def _options
  @_query_options.to_hash
end

#each(&block) ⇒ Object



48
49
50
# File 'lib/couch_view/proxy.rb', line 48

def each(&block)
  _model.send(_map, _options).each &block
end

#get!Object



52
53
54
# File 'lib/couch_view/proxy.rb', line 52

def get!
  _model.send _map, _options
end