Class: MerbFootnotes::Notes::AbstractNote

Inherits:
Object
  • Object
show all
Defined in:
lib/merb_footnotes/notes/abstract_note.rb

Overview

This is the abstrac class for notes.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller = nil) ⇒ AbstractNote

Initialize notes. Always receives a controller.



48
49
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 48

def initialize(controller = nil)
end

Class Method Details

.close!(controller = nil) ⇒ Object

Action to be called after the Note was used. This is applied as an after_filter.



41
42
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 41

def close!(controller = nil)
end

.included?Boolean

Return true if Note is included in notes array.

Returns:

  • (Boolean)


28
29
30
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 28

def included?
  MerbFootnotes::Filter.notes.include?(self.to_sym)
end

.start!(controller = nil) ⇒ Object

Action to be called to start the Note. This is applied as a before_filter.



35
36
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 35

def start!(controller = nil)
end

.titleObject

Returns the title that represents this note. It’s the name of the class without Note.

For example, for ControllerNote it will return Controller.



22
23
24
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 22

def title
  @note_title ||= self.name.match(/^MerbFootnotes::Notes::(\w+)Note$/)[1]
end

.to_symObject

Returns the symbol that represents this note. It’s the name of the class, underscored and without _note.

For example, for ControllerNote it will return :controller.



13
14
15
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 13

def to_sym
  @note_sym ||= self.title.to_const_path.to_sym
end

Instance Method Details

#fieldset?Boolean

Specifies when should create a fieldset for it, considering it’s valid.

Returns:

  • (Boolean)


117
118
119
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 117

def fieldset?
  self.respond_to?(:content)
end

#included?Boolean

Return if this note is incuded in MerbFootnotes::Filter.notes.

Returns:

  • (Boolean)


123
124
125
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 123

def included?
  self.class.included?
end

#javascriptObject

Insert here any additional javascript. This is directly inserted into a <script> tag.



105
106
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 105

def javascript
end

#legendObject

If fieldset?, create a fieldset with the value returned as legend. By default, returns the title of the class (defined above).



74
75
76
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 74

def legend
  self.class.title
end

Set href field for Footnotes links. If it’s nil, Footnotes will use ‘#’.



87
88
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 87

def link
end

#onclickObject

Set onclick field for Footnotes links. If it’s nil, Footnotes will make it open the fieldset.



93
94
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 93

def onclick
end

#rowObject

Specifies in which row should appear the title. The default is :show.



60
61
62
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 60

def row
  :show
end

#stylesheetObject

Insert here any additional stylesheet. This is directly inserted into a <style> tag.



99
100
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 99

def stylesheet
end

#titleObject

If valid?, create a tab on Footnotes Footer with the title returned. By default, returns the title of the class (defined above).



67
68
69
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 67

def title
  self.class.title
end

#to_symObject

Returns the symbol that represents this note.



53
54
55
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 53

def to_sym
  self.class.to_sym
end

#valid?Boolean

Specifies when should create a note for it. By default, it’s valid.

Returns:

  • (Boolean)


111
112
113
# File 'lib/merb_footnotes/notes/abstract_note.rb', line 111

def valid?
  true
end