Module: Persistence::Object::Flat::File::ObjectInstance
- Includes:
- FilePersistence
- Included in:
- Persistence::Object::Flat::File
- Defined in:
- lib/persistence/object/flat/file/object_instance.rb
Overview
Instance methods for File objects enabled with persistence capabilities.
Instance Method Summary collapse
-
#persist!(*args) ⇒ Object
persist! #.
-
#persists_file_paths_as_objects? ⇒ Boolean
persists_file_paths_as_objects? #.
-
#persists_file_paths_as_strings? ⇒ Boolean
persists_file_paths_as_strings? #.
-
#persists_files_by_content? ⇒ Boolean
persists_files_by_content? #.
-
#persists_files_by_path? ⇒ Boolean
persists_files_by_path? #.
Methods included from FilePersistence
#persist_file_paths_as_objects!, #persist_file_paths_as_strings!, #persist_files_by_content!, #persist_files_by_path!
Instance Method Details
#persist!(*args) ⇒ Object
persist! #
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/persistence/object/flat/file/object_instance.rb', line 13 def persist!( *args ) starting_pos = self.pos # if we are persisting by file path persistence_instance = nil if persists_files_by_path? persistence_instance = ::Persistence::Object::Flat::File::Path.new( path ) # if we are persisting by file contents else persistence_instance = ::Persistence::Object::Flat::File::Contents.new( self.readlines.join ) end persistence_instance.persistence_port = persistence_port persistence_instance.persistence_bucket = persistence_bucket # set new instance ID to current ID persistence_instance.persistence_id = persistence_id persistence_instance.persist!( *args ) # if we got ID from persist! on our instance set our own ID to it self.persistence_id = persistence_instance.persistence_id # rewind file to wherever we started self.pos = starting_pos return self end |
#persists_file_paths_as_objects? ⇒ Boolean
persists_file_paths_as_objects? #
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/persistence/object/flat/file/object_instance.rb', line 84 def persists_file_paths_as_objects? persists_file_paths_as_objects = nil persists_file_paths_as_objects = super if persists_file_paths_as_objects.nil? persists_file_paths_as_objects = self.class.persists_file_paths_as_objects? end return persists_file_paths_as_objects end |
#persists_file_paths_as_strings? ⇒ Boolean
persists_file_paths_as_strings? #
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/persistence/object/flat/file/object_instance.rb', line 102 def persists_file_paths_as_strings? persists_file_paths_as_strings = nil persists_file_paths_as_strings = super if persists_file_paths_as_strings.nil? persists_file_paths_as_strings = self.class.persists_file_paths_as_strings? end return persists_file_paths_as_strings end |
#persists_files_by_content? ⇒ Boolean
persists_files_by_content? #
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/persistence/object/flat/file/object_instance.rb', line 48 def persists_files_by_content? persists_files_by_content = nil persists_files_by_content = super if persists_files_by_content.nil? persists_files_by_content = self.class.persists_files_by_content? end return persists_files_by_content end |
#persists_files_by_path? ⇒ Boolean
persists_files_by_path? #
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/persistence/object/flat/file/object_instance.rb', line 66 def persists_files_by_path? persists_files_by_path = nil persists_files_by_path = super if persists_files_by_path.nil? persists_files_by_path = self.class.persists_files_by_path? end return persists_files_by_path end |