Sha256: 27015dc0bca12dfcc0f2c241c2f2477dc7acd015275ca035ffc68deed1b9abce
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
module CouchSurfer module Query module ClassMethods def query_processor(name) self.external = name end def query(view_name, query_string, query_options = {}) payload = { :design => self.send(:design_doc_slug), :view => set_view_options(view_name, query_options), :external => set_external_options(query_string), } result = CouchRest.post "http://#{database}/_mix", payload result['rows'].collect{|r|new(r['doc'])} if result['rows'] end private def set_view_options(view_name, query_options) {:name => view_name, :query => {:include_docs => true}.merge(query_options)} end def set_external_options(query_string) {:name => external, :query => {:q => query_string}, :include_docs => true} end end def self.included(receiver) receiver.extend ClassMethods receiver.class_eval do class_inheritable_accessor :external end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
couch_surfer-0.3.4 | lib/couch_surfer/query.rb |
couch_surfer-0.3.3 | lib/couch_surfer/query.rb |
couch_surfer-0.3.2 | lib/couch_surfer/query.rb |