Class: CouchDB::Design

Inherits:
Document show all
Defined in:
lib/couchdb/design.rb,
lib/couchdb/design/view.rb

Overview

See CouchDB::Design class for description.

Defined Under Namespace

Classes: View, ViewsProxy

Instance Attribute Summary collapse

Attributes inherited from Document

#database

Instance Method Summary collapse

Methods inherited from Document

#==, #[], #[]=, #clear_rev, #destroy, #exists?, #fetch_rev, #load, #new?, #rev, #rev=, #rev?, #save

Constructor Details

#initialize(database, id, language = "javascript") ⇒ Design

Returns a new instance of Design.



12
13
14
15
16
# File 'lib/couchdb/design.rb', line 12

def initialize(database, id, language = "javascript")
  super database
  self.id, self.language = id, language
  @views = ViewsProxy.new self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CouchDB::Document

Instance Attribute Details

#languageObject

Returns the value of attribute language.



9
10
11
# File 'lib/couchdb/design.rb', line 9

def language
  @language
end

#viewsObject (readonly)

Returns the value of attribute views.



10
11
12
# File 'lib/couchdb/design.rb', line 10

def views
  @views
end

Instance Method Details

#idObject



18
19
20
21
# File 'lib/couchdb/design.rb', line 18

def id
  id = super
  id ? id.sub(/^_design\//, "") : nil
end

#id=(value) ⇒ Object



23
24
25
# File 'lib/couchdb/design.rb', line 23

def id=(value)
  super((value =~ /^_design\//) ? value : "_design/#{value}")
end

#urlObject



35
36
37
# File 'lib/couchdb/design.rb', line 35

def url
  "#{self.database.url}/_design/#{self.id}"
end