Class: Notes

Inherits:
Dynasnip show all
Defined in:
lib/vanilla/dynasnips/notes.rb

Instance Attribute Summary

Attributes inherited from Vanilla::Renderers::Base

#app

Instance Method Summary collapse

Methods inherited from Dynasnip

all, attribute, build_snip, #method_missing, persist!, persist_all!, snip_attributes, snip_name, usage

Methods inherited from Vanilla::Renderers::Base

escape_curly_braces, #include_snips, #initialize, #prepare, #process_text, #raw_content, render, #render, #render_without_including_snips, snip_regexp

Constructor Details

This class inherits a constructor from Vanilla::Renderers::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dynasnip

Instance Method Details

#get(*args) ⇒ Object



4
5
6
7
8
9
# File 'lib/vanilla/dynasnips/notes.rb', line 4

def get(*args)
  all_notes_content = all_notes.map { |snip| 
    render_note(snip) 
  }.join("")
  snip.main_template.gsub('[notes]', all_notes_content)
end

#post(*args) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/vanilla/dynasnips/notes.rb', line 11

def post(*args)
  new_note = Snip.new(cleaned_params)
  new_note.name = "note_#{snip.next_note_id}"
  new_note.kind = "note"
  new_note.save
  increment_next_id
  get(*args)
end