Class: SnippetBlob

Inherits:
Object
  • Object
show all
Includes:
BlobLike
Defined in:
app/models/snippet_blob.rb

Constant Summary

Constants included from Gitlab::BlobHelper

Gitlab::BlobHelper::MEGABYTE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BlobLike

#binary_in_repo?, #external_size, #external_storage, #id, #load_all_data!, #mode, #truncated?

Methods included from Gitlab::BlobHelper

#_mime_type, #binary_in_repo?, #binary_mime_type?, #content_type, #empty?, #encoded_newlines_re, #encoding, #extname, #image?, #known_extension?, #large?, #lines, #mime_type, #ruby_encoding, #text_in_repo?, #viewable?

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(snippet) ⇒ SnippetBlob

Returns a new instance of SnippetBlob.


8
9
10
# File 'app/models/snippet_blob.rb', line 8

def initialize(snippet)
  @snippet = snippet
end

Instance Attribute Details

#snippetObject (readonly)

Returns the value of attribute snippet.


6
7
8
# File 'app/models/snippet_blob.rb', line 6

def snippet
  @snippet
end

Instance Method Details

#commit_idObject


24
25
26
# File 'app/models/snippet_blob.rb', line 24

def commit_id
  nil
end

#dataObject


28
29
30
# File 'app/models/snippet_blob.rb', line 28

def data
  snippet.content
end

#nameObject Also known as: path


14
15
16
# File 'app/models/snippet_blob.rb', line 14

def name
  snippet.file_name
end

#rendered_markupObject


32
33
34
35
36
# File 'app/models/snippet_blob.rb', line 32

def rendered_markup
  return unless Gitlab::MarkupHelper.gitlab_markdown?(name)

  Banzai.render_field(snippet, :content)
end

#sizeObject


20
21
22
# File 'app/models/snippet_blob.rb', line 20

def size
  data.bytesize
end