class Couchbase::DesignDoc

Attributes

spatial[RW]

The list of spatial views defined or empty array

@since 1.2.1

@return [Array<View>]

views[RW]

The list of views defined or empty array

@since 1.2.1

@return [Array<View>]

Public Class Methods

new(bucket, doc) click to toggle source
# 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

Public Instance Methods

has_views?() click to toggle source

Check if the document has views defines

@since 1.2.1

@see DesignDoc#views

@return [true, false] true if the document have views

# File lib/couchbase/design_doc.rb, line 69
def has_views?
  !@views.empty?
end
inspect() click to toggle source
# 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
method_missing(meth, *args) click to toggle source
Calls superclass method
# 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
respond_to_missing?(meth, *args) click to toggle source
Calls superclass method
# File lib/couchbase/design_doc.rb, line 44
def respond_to_missing?(meth, *args)
  @all_views[meth.to_s] || super
end