Class: Gitlab::GithubImport::Representation::NoteText
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::Representation::NoteText
- Includes:
- Representable
- Defined in:
- lib/gitlab/github_import/representation/note_text.rb
Constant Summary collapse
- MODELS_ALLOWLIST =
[::Release, ::Note, ::Issue, ::MergeRequest].freeze
- ModelNotSupported =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#object_type ⇒ Object
Returns the value of attribute object_type.
Class Method Summary collapse
-
.from_db_record(record) ⇒ Object
Builds a note text representation from DB record of Note or Release.
- .from_json_hash(raw_hash) ⇒ Object
Instance Method Summary collapse
- #github_identifiers ⇒ Object
-
#initialize(attributes) ⇒ NoteText
constructor
attributes - A Hash containing the event details.
Constructor Details
#initialize(attributes) ⇒ NoteText
attributes - A Hash containing the event details. The keys of this
Hash (and any nested hashes) must be symbols.
50 51 52 |
# File 'lib/gitlab/github_import/representation/note_text.rb', line 50 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
#object_type ⇒ Object
Returns the value of attribute object_type.
18 19 20 |
# File 'lib/gitlab/github_import/representation/note_text.rb', line 18 def object_type @object_type end |
Class Method Details
.from_db_record(record) ⇒ Object
Builds a note text representation from DB record of Note or Release.
record - An instance of Note, Release, Issue, MergeRequest model
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/github_import/representation/note_text.rb', line 23 def self.from_db_record(record) check_record_class!(record) record_type = record.class.name # only column for note is different along MODELS_ALLOWLIST text = record.is_a?(::Note) ? record.note : record.description new( record_db_id: record.id, record_type: record_type, text: text, iid: record.try(:iid), tag: record.try(:tag), noteable_type: record.try(:noteable_type) ) end |
.from_json_hash(raw_hash) ⇒ Object
39 40 41 |
# File 'lib/gitlab/github_import/representation/note_text.rb', line 39 def self.from_json_hash(raw_hash) new Representation.symbolize_hash(raw_hash) end |
Instance Method Details
#github_identifiers ⇒ Object
54 55 56 57 58 |
# File 'lib/gitlab/github_import/representation/note_text.rb', line 54 def github_identifiers { db_id: record_db_id }.merge(record_type_specific_attribute) end |