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 |
# File 'lib/dayvan/design.rb', line 35 def config_val('attachment_path', 'attachments_path', 'attachments') || 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
71 72 73 |
# File 'lib/dayvan/design.rb', line 71 def push doc.put to_json end |
#to_hash ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/dayvan/design.rb', line 59 def to_hash { '_rev' => rev, '_attachments' => , 'views' => views, 'validate_doc_update' => validate_doc_update }.reject {|key, val| !val} end |
#to_json ⇒ Object
67 68 69 |
# File 'lib/dayvan/design.rb', line 67 def to_json to_hash.to_json end |
#validate_doc_update ⇒ Object
49 50 51 |
# File 'lib/dayvan/design.rb', line 49 def validate_doc_update Dayvan::Validation.all(validate_doc_update_path) end |
#validate_doc_update_path ⇒ Object
53 54 55 56 |
# File 'lib/dayvan/design.rb', line 53 def validate_doc_update_path config_val('validation_path', 'validate_path', 'validation') || Dayvan.project.dir.join('config','validation.coffee') end |