Class: Couchbase::DesignDoc
- Defined in:
- lib/couchbase/design_doc.rb
Constant Summary
Constants included from Constants
Constants::S_CAS, Constants::S_DOC, Constants::S_FLAGS, Constants::S_ID, Constants::S_IS_LAST, Constants::S_KEY, Constants::S_META, Constants::S_VALUE
Instance Attribute Summary collapse
-
#spatial ⇒ Array<View>
The list of spatial views defined or empty array.
-
#views ⇒ Array<View>
The list of views defined or empty array.
Attributes inherited from ViewRow
#data, #doc, #id, #key, #meta, #value
Instance Method Summary collapse
-
#has_views? ⇒ true, false
Check if the document has views defines.
-
#initialize(bucket, doc) ⇒ DesignDoc
constructor
A new instance of DesignDoc.
- #inspect ⇒ Object
- #method_missing(meth, *args) ⇒ Object
- #respond_to_missing?(meth, *args) ⇒ Boolean
Methods inherited from ViewRow
#[], #[]=, #has_key?, #last?, wrap
Constructor Details
#initialize(bucket, doc) ⇒ DesignDoc
Returns a new instance of DesignDoc.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/couchbase/design_doc.rb', line 25 def initialize(bucket, doc) @all_views = {} @bucket = bucket @name = doc.name @views = doc.views @spatial = doc.spatial_views @doc = {} @views.each { |view| @all_views[view.name] = "#{@name}/_view/#{view.name}" } @spatial.each { |view| @all_views[view.name] = "#{@name}/_spatial/#{view.name}" } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/couchbase/design_doc.rb', line 36 def method_missing(meth, *args) if path = @all_views[meth.to_s] View.new(@bucket, path, *args) else super end end |
Instance Attribute Details
#spatial ⇒ Array<View>
The list of spatial views defined or empty array
60 61 62 |
# File 'lib/couchbase/design_doc.rb', line 60 def spatial @spatial end |
#views ⇒ Array<View>
The list of views defined or empty array
53 54 55 |
# File 'lib/couchbase/design_doc.rb', line 53 def views @views end |
Instance Method Details
#has_views? ⇒ true, false
Check if the document has views defines
69 70 71 |
# File 'lib/couchbase/design_doc.rb', line 69 def has_views? !@views.empty? end |
#inspect ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/couchbase/design_doc.rb', line 73 def inspect desc = "#<#{self.class.name}:#{self.object_id}" [:@id, :@views, :@spatial].each do |iv| desc << " #{iv}=#{instance_variable_get(iv).inspect}" end desc << ">" desc end |
#respond_to_missing?(meth, *args) ⇒ Boolean
44 45 46 |
# File 'lib/couchbase/design_doc.rb', line 44 def respond_to_missing?(meth, *args) @all_views[meth.to_s] || super end |