Class: Metadata::Metadatum

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/migrations/metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Metadatum

Returns a new instance of Metadatum.



44
45
46
47
48
49
# File 'lib/i18n/migrations/metadata.rb', line 44

def initialize(hash)
  safe_hash = hash || {}
  @errors = safe_hash['errors'] || []
  @notes = safe_hash['notes']
  @autotranslated = !!safe_hash['autotranslated']
end

Instance Attribute Details

#autotranslatedObject

Returns the value of attribute autotranslated.



42
43
44
# File 'lib/i18n/migrations/metadata.rb', line 42

def autotranslated
  @autotranslated
end

#errorsObject

Returns the value of attribute errors.



42
43
44
# File 'lib/i18n/migrations/metadata.rb', line 42

def errors
  @errors
end

#notesObject

Returns the value of attribute notes.



42
43
44
# File 'lib/i18n/migrations/metadata.rb', line 42

def notes
  @notes
end

Instance Method Details

#to_hObject



51
52
53
54
55
56
57
# File 'lib/i18n/migrations/metadata.rb', line 51

def to_h
  hash = {}
  hash['errors'] = @errors unless @errors.empty?
  hash['notes'] = @notes unless @notes.blank?
  hash['autotranslated'] = @autotranslated if autotranslated
  hash
end