Module: Persistence::Cursor::Atomic

Defined in:
lib/persistence/cursor/atomic.rb

Overview

Cursor subclass that automatically performs atomic lookups on attributes.

Instance Method Summary collapse

Instance Method Details

#currentObject+

Persist current object in cursor context.

Returns:



83
84
85
86
87
# File 'lib/persistence/cursor/atomic.rb', line 83

def current
  current_value = super
  current_value.attrs_atomic! if current_value
  return current_value
end

#first(count = 1) ⇒ Object+

Persist first object in cursor context.

Parameters:

  • count (Integer) (defaults to: 1)

    How many objects to persist from start of cursor context.

Returns:



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/persistence/cursor/atomic.rb', line 62

def first( count = 1 )
  first_values = super
  if first_values.is_a?( ::Array )
    first_values.each do |this_value|
      this_value.attrs_atomic!
    end
  elsif first_values
    first_values.attrs_atomic!
  end
  return first_values
end

#get_object(global_id) ⇒ Object

Get object for persistence ID using atomic attribute loading, regardless how attributes are declared.

Parameters:

  • global_id

    Persistence ID to retrieve object.

Returns:

  • (Object)

    Object being retrieved for persistence ID.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/persistence/cursor/atomic.rb', line 18

def get_object( global_id )
  
  klass = @persistence_bucket.parent_port.get_class_for_object_id( global_id )
  
  object = nil
  
  if klass
    object = klass.new
    object.persistence_id = global_id
    object.attrs_atomic!
  end
  
  return object

end

#next(count = 1) ⇒ Object

Return the next object in cursor’s current context.

Returns:

  • (Object)

    Next object in cursor’s current context.



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/persistence/cursor/atomic.rb', line 98

def next( count = 1 )
  next_values = super
  if next_values.is_a?( ::Array )
    next_values.each do |this_value|
      this_value.attrs_atomic!
    end
  elsif next_values
    next_values.attrs_atomic!
  end
  return next_values
end

#persist(key) ⇒ Object

Load object with specified persistence ID.

Parameters:

  • key

    Key to retrieve.

Returns:

  • (Object)

    Object for persistence ID.



45
46
47
48
49
# File 'lib/persistence/cursor/atomic.rb', line 45

def persist( key )
  
  return super.attrs_atomic!

end