Module: Persistence::Object::ParsePersistenceArgs

Included in:
ClassInstance, ObjectInstance
Defined in:
lib/persistence/object/parse_persistence_args.rb

Overview

Internal helper for parsing args of the format: method, method( global_id ), method( index_name, value ),

method( index_instance, value ), method( index_name => value ), method( index_instance => value ).

Defined Under Namespace

Modules: ClassInstance, ObjectInstance

Instance Method Summary collapse

Instance Method Details

#process_file_key(file_key) ⇒ Persistence::Object::Flat::File::Path, Persistence::Object::Flat::File::Contents

Internal helper method to handle instances of File as key.

Parameters:

  • file_key (File)

    File instance to process as key.

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/persistence/object/parse_persistence_args.rb', line 21

def process_file_key( file_key )

  # do we have a file key? if so we need to replace it with File::Path or File::Contents

  processed_key = nil
  
  if file_key.persists_files_by_path?
    processed_key = ::Persistence::Object::Flat::File::Path.new( file_key.path )
  else
    starting_pos  = file_key.pos
    processed_key = ::Persistence::Object::Flat::File::Contents.new( file_key.readlines.join )
    file_key.pos  = starting_pos
  end
  
  return processed_key
  
end