Module: Aqua::Pack::InstanceMethods

Defined in:
lib/aqua/object/pack.rb

Overview

ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_revObject

Returns the value of attribute _rev.



135
136
137
# File 'lib/aqua/object/pack.rb', line 135

def _rev
  @_rev
end

#_warningsObject

Returns the value of attribute _warnings.



135
136
137
# File 'lib/aqua/object/pack.rb', line 135

def _warnings
  @_warnings
end

Instance Method Details

#_embedded?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Details from configuration options for the objects class about embedability.

Returns:

  • (true, false)

    If true then it should be embedded in the base object. If false, then it should be saved externally.



131
132
133
# File 'lib/aqua/object/pack.rb', line 131

def _embedded? 
  self.class._aqua_opts[:embed] == true
end

#_packStorage

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

packs an object from it’s Ruby state into a Hash-like object for storage.

Returns:



89
90
91
92
93
94
95
96
97
# File 'lib/aqua/object/pack.rb', line 89

def _pack
  class_name = self.class.to_s
  self.__pack = Storage.new
  self.__pack.id = @id if @id
  self.__pack[:_rev] = _rev if _rev 
  self.__pack.merge!( _translator.pack_object( self ) ) 
  _pack_attachments
  __pack
end

#_pack_attachmentsObject



99
100
101
102
103
# File 'lib/aqua/object/pack.rb', line 99

def _pack_attachments 
  _translator.attachments.each do |file|
    self.__pack.attachments.add( file.filename, file )
  end  
end

#_stubbed_methodstrue, ...

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Details from configuration options for the objects class about embedability.

Returns:

  • (true, false, Hash)

    If true then it should be embedded in the object at hand. If false, then it should be saved externally. If a hash, with the key :stub and a related value that is an array of methods, then the object should be saved externally, with a few cached methods as defined in the array.



121
122
123
124
# File 'lib/aqua/object/pack.rb', line 121

def _stubbed_methods 
  meths = !_embedded? && self.class._aqua_opts[:embed] && self.class._aqua_opts[:embed][:stub]
  meths ? [meths].flatten : []
end

#_translatorTranslator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Translator object responsible for packing the object and keeping track of externally stored records and also attachments

Returns:



110
111
112
# File 'lib/aqua/object/pack.rb', line 110

def _translator
  @_translator ||= Translator.new( self )
end

#commitObject

Saves object; returns false on failure; returns self on success.



76
77
78
# File 'lib/aqua/object/pack.rb', line 76

def commit 
  _commit
end

#commit!Object

Saves object and raises an error on failure



81
82
83
# File 'lib/aqua/object/pack.rb', line 81

def commit!
  _commit( false )
end