Class: Git::WikiPushService::Change

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/git/wiki_push_service/change.rb

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(wiki, change, raw_change) ⇒ Change

Returns a new instance of Change.

Parameters:


11
12
13
# File 'app/services/git/wiki_push_service/change.rb', line 11

def initialize(wiki, change, raw_change)
  @wiki, @raw_change, @change = wiki, raw_change, change
end

Instance Method Details

#event_actionObject

See [Gitlab::Git::RawDiffChange#extract_operation] for the definition of the full range of operation values.


21
22
23
24
25
26
27
28
29
30
# File 'app/services/git/wiki_push_service/change.rb', line 21

def event_action
  case raw_change.operation
  when :added
    :created
  when :deleted
    :destroyed
  else
    :updated
  end
end

#last_known_slugObject


32
33
34
# File 'app/services/git/wiki_push_service/change.rb', line 32

def last_known_slug
  strip_extension(raw_change.old_path || raw_change.new_path)
end

#pageObject


15
16
17
# File 'app/services/git/wiki_push_service/change.rb', line 15

def page
  strong_memoize(:page) { wiki.find_page(slug, revision) }
end

#shaObject


36
37
38
# File 'app/services/git/wiki_push_service/change.rb', line 36

def sha
  change[:newrev]
end