class Boombera::ContentItem

ContentItem is a specialization of CouchRest::Document that adds content-mapping semantics and method-based access to the attributes that Boombera knows about.

Attributes

body[RW]

The actual content that is being stored

path[R]

The path used to access the ContentItem, it is stored as the ‘_id’ attribute in CouchDB

Public Class Methods

get(path, db) click to toggle source
# File lib/boombera/content_item.rb, line 12
def self.get(path, db)
  doc = get_pointer(path, db)
  until doc.nil? || doc.resolved?
    doc = get_pointer(doc.maps_to, db)
  end
  doc
end
get_pointer(path, db) click to toggle source
# File lib/boombera/content_item.rb, line 20
def self.get_pointer(path, db)
  Boombera::ContentItem.new(db.get(path))
rescue RestClient::ResourceNotFound
  nil
end

Public Instance Methods

referenced_by() click to toggle source

Returns the paths that are aliased to this ContentItem

# File lib/boombera/content_item.rb, line 51
def referenced_by
  rows = @database.view('boombera/map_references', :key => path)['rows']
  rows.map{ |row| row['value'] }.sort
end
resolved?() click to toggle source
# File lib/boombera/content_item.rb, line 62
def resolved?
  path == maps_to
end
save(*args) click to toggle source
Calls superclass method
# File lib/boombera/content_item.rb, line 56
def save(*args)
  self['maps_to'] = maps_to
  self['type'] = 'content_item'
  super
end