Class: Loveseat::DesignDocument::Support

Inherits:
Loveseat::Document::Support show all
Defined in:
lib/loveseat/design_document/support.rb

Constant Summary

Constants inherited from Loveseat::Document::Support

Loveseat::Document::Support::DEFAULT, Loveseat::Document::Support::TYPE

Instance Attribute Summary

Attributes inherited from Loveseat::Document::Support

#dsl, #properties

Instance Method Summary collapse

Methods inherited from Loveseat::Document::Support

#abstract?, #add_property, #alter_property, #generate_property_map, #singleton?, #to_doc

Constructor Details

#initialize(klass, options = {}) ⇒ Support

Returns a new instance of Support.



4
5
6
7
8
9
# File 'lib/loveseat/design_document/support.rb', line 4

def initialize(klass, options = {})
  super(klass, options)
  @dsl = DSL.new(self)
  add_property(:views, Document::Property::Hash, {})
  alter_property(:_id, Document::Property::String, DesignDocument.generate_id(klass))
end

Instance Method Details

#add_view(name, options = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/loveseat/design_document/support.rb', line 17

def add_view(name, options = {})
  type, default = properties[:views]
  default.merge!(
    name => options
  )
end

#from_hash(doc) ⇒ Object



11
12
13
14
15
# File 'lib/loveseat/design_document/support.rb', line 11

def from_hash(doc)
  object = super(doc)
  object.views = properties[:views][DEFAULT]
  object
end