Class: Dayvan::Design
- Inherits:
-
Object
- Object
- Dayvan::Design
- Defined in:
- lib/dayvan/design.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
- #rev ⇒ Object
Class Method Summary collapse
Instance Method Summary collapse
- #attachment_path ⇒ Object
- #attachments ⇒ Object
- #doc ⇒ Object
- #id ⇒ Object
- #push ⇒ Object
- #to_hash ⇒ Object
- #to_json ⇒ Object
- #validate_doc_update ⇒ Object
- #validate_doc_update_path ⇒ Object
- #view_path ⇒ Object
- #views ⇒ Object
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/dayvan/design.rb', line 3 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/dayvan/design.rb', line 3 def name @name end |
#rev ⇒ Object
26 27 28 29 |
# File 'lib/dayvan/design.rb', line 26 def rev @rev ||= JSON.parse(doc.get)['_rev'] rescue RestClient::ResourceNotFound end |
Class Method Details
.new_from_config(name, config = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dayvan/design.rb', line 6 def self.new_from_config(name, config={}) returning(new) do |d| if name.is_a?(Hash) d.name = name.delete('name') d.config = name else d.name = name d.config = config end end end |
Instance Method Details
#attachment_path ⇒ Object
35 36 37 38 39 |
# File 'lib/dayvan/design.rb', line 35 def config['attachments'] || config['attachment'] || Dayvan.project.dir.join('public') end |
#attachments ⇒ Object
31 32 33 |
# File 'lib/dayvan/design.rb', line 31 def Dayvan::Attachment.all() end |
#id ⇒ Object
22 23 24 |
# File 'lib/dayvan/design.rb', line 22 def id "_design/#{name}" end |
#push ⇒ Object
73 74 75 |
# File 'lib/dayvan/design.rb', line 73 def push doc.put to_json end |
#to_hash ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/dayvan/design.rb', line 61 def to_hash hsh = { '_attachments' => , 'views' => views, 'validate_doc_update' => validate_doc_update } rev ? hsh.merge('_rev' => rev) : hsh end |
#to_json ⇒ Object
69 70 71 |
# File 'lib/dayvan/design.rb', line 69 def to_json to_hash.to_json end |
#validate_doc_update ⇒ Object
51 52 53 |
# File 'lib/dayvan/design.rb', line 51 def validate_doc_update Dayvan::Security.new(validate_doc_update_path) end |
#validate_doc_update_path ⇒ Object
55 56 57 58 |
# File 'lib/dayvan/design.rb', line 55 def validate_doc_update_path config['security'] || Dayvan.project.dir.join('config','security.coffee') end |