Class: Pressy::RemoteChangeset::UpdatedPost

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rendered_post, post) ⇒ UpdatedPost

Returns a new instance of UpdatedPost



77
78
79
80
# File 'lib/pressy/changeset/remote.rb', line 77

def initialize(rendered_post, post)
  @rendered_post = rendered_post
  @post = post
end

Instance Attribute Details

#postObject (readonly)

Returns the value of attribute post



75
76
77
# File 'lib/pressy/changeset/remote.rb', line 75

def post
  @post
end

#rendered_postObject (readonly)

Returns the value of attribute rendered_post



75
76
77
# File 'lib/pressy/changeset/remote.rb', line 75

def rendered_post
  @rendered_post
end

Instance Method Details

#==(other) ⇒ Object



97
98
99
# File 'lib/pressy/changeset/remote.rb', line 97

def ==(other)
  rendered_post == other.rendered_post && post == other.post
end

#execute(store, client) ⇒ Object



82
83
84
85
86
87
88
89
90
91
# File 'lib/pressy/changeset/remote.rb', line 82

def execute(store, client)
  saved = client.edit_post(post)
  rendered = Pressy::PostRenderer.render(saved)

  if rendered_post.path != rendered.path
    store.delete(saved.id, rendered_post)
  end

  store.write(saved.id, rendered)
end

#typeObject



93
94
95
# File 'lib/pressy/changeset/remote.rb', line 93

def type
  :update
end