Class: Pressy::LocalChangeset::UpdatedPost

Inherits:
Object
  • Object
show all
Defined in:
lib/pressy/changeset/local.rb

Querying the Changes collapse

Querying the Changes collapse

Constructor Details

#initialize(id, existing, updated) ⇒ UpdatedPost

Returns a new instance of UpdatedPost



110
111
112
113
114
# File 'lib/pressy/changeset/local.rb', line 110

def initialize(id, existing, updated)
  @id = id
  @existing_post = existing
  @updated_post = updated
end

Instance Attribute Details

#existing_postObject (readonly)

Returns the value of attribute existing_post



108
109
110
# File 'lib/pressy/changeset/local.rb', line 108

def existing_post
  @existing_post
end

#idObject (readonly)

Returns the value of attribute id



108
109
110
# File 'lib/pressy/changeset/local.rb', line 108

def id
  @id
end

#updated_postObject (readonly)

Returns the value of attribute updated_post



108
109
110
# File 'lib/pressy/changeset/local.rb', line 108

def updated_post
  @updated_post
end

Instance Method Details

#==(other) ⇒ Object



128
129
130
# File 'lib/pressy/changeset/local.rb', line 128

def ==(other)
  existing_post == other.existing_post && updated_post == other.updated_post
end

#execute(store) ⇒ Object



116
117
118
119
120
121
122
# File 'lib/pressy/changeset/local.rb', line 116

def execute(store)
  if existing_post.path != updated_post.path
    store.delete(id, existing_post)
  end

  store.write(id, updated_post)
end

#typeObject



124
125
126
# File 'lib/pressy/changeset/local.rb', line 124

def type
  :update
end