Class: Troo::CommentPersistence

Inherits:
Object
  • Object
show all
Defined in:
lib/troo/models/comment_persistence.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, options = {}) ⇒ CommentPersistence

Returns a new instance of CommentPersistence.



9
10
11
12
# File 'lib/troo/models/comment_persistence.rb', line 9

def initialize(resource, options = {})
  @resource = resource
  @options = options
end

Class Method Details

.for(resource, options = {}) ⇒ Object



4
5
6
# File 'lib/troo/models/comment_persistence.rb', line 4

def for(resource, options = {})
  new(resource, options).persist
end

Instance Method Details

#persistObject



14
15
16
17
18
# File 'lib/troo/models/comment_persistence.rb', line 14

def persist
  return local   if local_identical?
  return updated if local_exists?
  return created
end