Class: Plain::Document
- Inherits:
-
Object
- Object
- Plain::Document
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/plain/document.rb
Overview
app/models/document.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#current_path ⇒ Object
Returns the value of attribute current_path.
-
#menu_position ⇒ Object
Returns the value of attribute menu_position.
-
#path ⇒ Object
Returns the value of attribute path.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
5 6 7 |
# File 'app/models/plain/document.rb', line 5 def content @content end |
#current_path ⇒ Object
Returns the value of attribute current_path.
5 6 7 |
# File 'app/models/plain/document.rb', line 5 def current_path @current_path end |
#menu_position ⇒ Object
Returns the value of attribute menu_position.
5 6 7 |
# File 'app/models/plain/document.rb', line 5 def @menu_position end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'app/models/plain/document.rb', line 5 def path @path end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'app/models/plain/document.rb', line 5 def title @title end |
Instance Method Details
#save ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/plain/document.rb', line 11 def save return false unless valid? # Ensure the directory exists FileUtils.mkdir_p(File.dirname(file_path)) # Write to the file File.open(file_path, 'w') do |file| file.write("---\n") file.write("title: #{title}\n") file.write("menu_position: #{}\n") file.write("---\n\n") file.write(self.content) end true rescue false end |