Class: Backup::Entry
- Inherits:
-
Object
- Object
- Backup::Entry
- Defined in:
- app/models/backup.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, title, extension, content) ⇒ Entry
constructor
A new instance of Entry.
- #path ⇒ Object
- #safe_key ⇒ Object
- #with_key(key) ⇒ Object
Constructor Details
#initialize(id, title, extension, content) ⇒ Entry
Returns a new instance of Entry.
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/backup.rb', line 76 def initialize(id, title, extension, content) if title title = "%05d_%s" % [id, title] else title = "%05d" % id end title = DatabaseFile.sanitize title extension = DatabaseFile.sanitize(extension || "") extension = ".#{extension}" if extension.present? @filename = "#{title}#{extension}" @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
74 75 76 |
# File 'app/models/backup.rb', line 74 def content @content end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
74 75 76 |
# File 'app/models/backup.rb', line 74 def filename @filename end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
74 75 76 |
# File 'app/models/backup.rb', line 74 def key @key end |
Class Method Details
.from_record(record) ⇒ Object
104 105 106 107 |
# File 'app/models/backup.rb', line 104 def from_record(record) title = record.zip_title if record.respond_to? :zip_title new record.id, title, "json", record.to_json end |
Instance Method Details
#path ⇒ Object
99 100 101 |
# File 'app/models/backup.rb', line 99 def path "#{safe_key}/#{filename}" end |
#safe_key ⇒ Object
95 96 97 |
# File 'app/models/backup.rb', line 95 def safe_key DatabaseFile.sanitize key.to_s end |
#with_key(key) ⇒ Object
90 91 92 93 |
# File 'app/models/backup.rb', line 90 def with_key(key) @key = key self end |