Class: Couchbase::DesignDoc
- Inherits:
-
Object
- Object
- Couchbase::DesignDoc
- Defined in:
- lib/couchbase/design_doc.rb
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.
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
Constructor Details
#initialize(bucket, doc) ⇒ DesignDoc
Returns a new instance of DesignDoc.
4 5 6 7 8 9 10 11 12 |
# File 'lib/couchbase/design_doc.rb', line 4 def initialize(bucket, doc) @all_views = {} @bucket = bucket @name = doc.name @views = doc.views @spatial = doc.spatial_views @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
14 15 16 17 18 19 20 |
# File 'lib/couchbase/design_doc.rb', line 14 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
38 39 40 |
# File 'lib/couchbase/design_doc.rb', line 38 def spatial @spatial end |
#views ⇒ Array<View>
The list of views defined or empty array
31 32 33 |
# File 'lib/couchbase/design_doc.rb', line 31 def views @views end |
Instance Method Details
#has_views? ⇒ true, false
Check if the document has views defines
47 48 49 |
# File 'lib/couchbase/design_doc.rb', line 47 def has_views? !@views.empty? end |
#inspect ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/couchbase/design_doc.rb', line 51 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
22 23 24 |
# File 'lib/couchbase/design_doc.rb', line 22 def respond_to_missing?(meth, *args) @all_views[meth.to_s] || super end |