Class: CouchView::Proxy
- Inherits:
-
Object
- Object
- CouchView::Proxy
- Extended by:
- Forwardable
- Defined in:
- lib/couch_view/proxy.rb
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) _map
readonly
Returns the value of attribute _map.
-
- (Object) _model
readonly
Returns the value of attribute _model.
-
- (Object) _query_options
Returns the value of attribute _query_options.
Instance Method Summary (collapse)
- - (Object) _options
- - (Object) each(&block)
- - (Object) get!
-
- (Proxy) initialize(model, map)
constructor
A new instance of Proxy.
- - (Object) method_missing(condition, *args, &block)
Constructor Details
- (Proxy) initialize(model, map)
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 = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(condition, *args, &block)
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
- (Object) _map (readonly)
Returns the value of attribute _map
5 6 7 8 9 |
# File 'lib/couch_view/proxy.rb', line 5 def _map map = [@_map.to_s, @_conditions.sort.join("_")] map.reject! &:blank? map.join("_").to_sym end |
- (Object) _model (readonly)
Returns the value of attribute _model
5 6 7 |
# File 'lib/couch_view/proxy.rb', line 5 def _model @_model end |
- (Object) _query_options
Returns the value of attribute _query_options
6 7 8 |
# File 'lib/couch_view/proxy.rb', line 6 def @_query_options end |
Instance Method Details
- (Object) _options
32 33 34 |
# File 'lib/couch_view/proxy.rb', line 32 def @_query_options.to_hash end |
- (Object) each(&block)
48 49 50 |
# File 'lib/couch_view/proxy.rb', line 48 def each(&block) _model.send(_map, ).each &block end |
- (Object) get!
52 53 54 |
# File 'lib/couch_view/proxy.rb', line 52 def get! _model.send _map, end |