Class: ActiveRecord::MigrationNotes::Handler
- Inherits:
-
Object
- Object
- ActiveRecord::MigrationNotes::Handler
- Includes:
- Singleton
- Defined in:
- lib/active_record/migration_notes/handler.rb
Instance Attribute Summary collapse
-
#notes ⇒ Object
Returns the value of attribute notes.
Instance Method Summary collapse
- #add(version, name, content, direction = :up) ⇒ Object
-
#initialize ⇒ Handler
constructor
A new instance of Handler.
- #output ⇒ Object
Constructor Details
#initialize ⇒ Handler
Returns a new instance of Handler.
10 11 12 |
# File 'lib/active_record/migration_notes/handler.rb', line 10 def initialize @notes = [] end |
Instance Attribute Details
#notes ⇒ Object
Returns the value of attribute notes.
8 9 10 |
# File 'lib/active_record/migration_notes/handler.rb', line 8 def notes @notes end |
Instance Method Details
#add(version, name, content, direction = :up) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/active_record/migration_notes/handler.rb', line 14 def add(version, name, content, direction = :up) content = ' ' + content.split("\n").map(&:strip).join("\n ") notes << { version: version, name: name, content: content, direction: direction } rescue nil end |
#output ⇒ Object
22 23 24 25 |
# File 'lib/active_record/migration_notes/handler.rb', line 22 def output migration_notes unless notes.empty? @notes = [] end |