Class: DatoDump::RecordDumper
- Inherits:
-
Object
- Object
- DatoDump::RecordDumper
- Defined in:
- lib/dato_dump/record_dumper.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(record, repo) ⇒ RecordDumper
constructor
A new instance of RecordDumper.
Constructor Details
#initialize(record, repo) ⇒ RecordDumper
Returns a new instance of RecordDumper.
9 10 11 12 |
# File 'lib/dato_dump/record_dumper.rb', line 9 def initialize(record, repo) @record = record @repo = repo end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
7 8 9 |
# File 'lib/dato_dump/record_dumper.rb', line 7 def record @record end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
7 8 9 |
# File 'lib/dato_dump/record_dumper.rb', line 7 def repo @repo end |
Instance Method Details
#dump ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dato_dump/record_dumper.rb', line 14 def dump attributes = { id: record.id } content_type = record.content_type content_type.fields.each do |field| attributes[field.api_key] = dump_attribute( record.send(field.api_key), field ) end if content_type.sortable attributes["position"] = record.position end attributes.to_h end |