Module: Diary::Item::Creator::Peristance

Defined in:
lib/diary/item/creator.rb

Instance Method Summary collapse

Instance Method Details

#persisted?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/diary/item/creator.rb', line 17

def persisted?
  File.exists?(path)
end

#save!(title = nil) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/diary/item/creator.rb', line 9

def save!(title = nil)
  unless persisted?
    self.class.create(title || basename)
  else
    self
  end
end