Class: Array

Inherits:
Object show all
Includes:
ODBA::Persistable
Defined in:
lib/odba/stub.rb,
lib/odba/persistable.rb

Overview

:nodoc: all

Constant Summary

Constants included from ODBA::Persistable

ODBA::Persistable::Exact, ODBA::Persistable::Find, ODBA::Persistable::ODBA_EXCLUDE_VARS, ODBA::Persistable::ODBA_INDEXABLE, ODBA::Persistable::ODBA_PREDEFINE_EXCLUDE_VARS, ODBA::Persistable::ODBA_PREDEFINE_SERIALIZABLE, ODBA::Persistable::ODBA_PREFETCH, ODBA::Persistable::ODBA_SERIALIZABLE

Instance Attribute Summary

Attributes included from ODBA::Persistable

#odba_id, #odba_name, #odba_persistent, #odba_prefetch

Instance Method Summary collapse

Methods included from ODBA::Persistable

append_features, #dup, #eql?, #odba_add_observer, #odba_delete, #odba_delete_observer, #odba_delete_observers, #odba_dup, #odba_exclude_vars, #odba_indexable?, #odba_isolated_dump, #odba_isolated_store, #odba_isolated_stub, #odba_isolated_twin, #odba_notify_observers, #odba_observers, #odba_potentials, #odba_replace_stubs, #odba_serializables, #odba_snapshot, #odba_store, #odba_store_unsaved, #odba_take_snapshot, sanitize

Instance Method Details

#&(stub) ⇒ Object



144
145
146
# File 'lib/odba/stub.rb', line 144

def &(stub)
  self._odba_amp(stub.odba_instance)
end

#+(stub) ⇒ Object



148
149
150
# File 'lib/odba/stub.rb', line 148

def +(stub)
  self._odba_plus(stub.odba_instance)
end

#-(stub) ⇒ Object



152
153
154
# File 'lib/odba/stub.rb', line 152

def -(stub)
  self._odba_minus(stub.odba_instance)
end

#<=>(stub) ⇒ Object



156
157
158
# File 'lib/odba/stub.rb', line 156

def <=>(stub)
  self._odba_weight(stub.odba_instance)
end

#==(stub) ⇒ Object



160
161
162
# File 'lib/odba/stub.rb', line 160

def ==(stub)
  self._odba_equal?(stub.odba_instance)
end

#_odba_ampObject



143
# File 'lib/odba/stub.rb', line 143

alias :_odba_amp :&

#_odba_equal?Object



159
# File 'lib/odba/stub.rb', line 159

alias :_odba_equal? :==

#_odba_minusObject



151
# File 'lib/odba/stub.rb', line 151

alias :_odba_minus :-

#_odba_plusObject



147
# File 'lib/odba/stub.rb', line 147

alias :_odba_plus :+

#_odba_unionObject



163
# File 'lib/odba/stub.rb', line 163

alias :_odba_union :|

#_odba_weightObject



155
# File 'lib/odba/stub.rb', line 155

alias :_odba_weight :<=>

#odba_collectionObject



485
486
487
488
489
490
491
# File 'lib/odba/persistable.rb', line 485

def odba_collection
  coll = []
  each_with_index { |item, index|
    coll.push([index, item])
  }
  coll
end

#odba_cut_connection(remove_object) ⇒ Object



492
493
494
495
# File 'lib/odba/persistable.rb', line 492

def odba_cut_connection(remove_object)
  super(remove_object)
  delete_if { |val| val.eql?(remove_object) }
end

#odba_prefetch?Boolean

Returns:

  • (Boolean)


496
497
498
499
500
501
# File 'lib/odba/persistable.rb', line 496

def odba_prefetch?
  super || any? { |item|
    item.respond_to?(:odba_prefetch?) \
      && item.odba_prefetch?
  }
end

#odba_replace!(obj) ⇒ Object

:nodoc:



502
503
504
505
# File 'lib/odba/persistable.rb', line 502

def odba_replace!(obj) # :nodoc:
  super
  replace(obj)
end

#odba_replace_persistablesObject



506
507
508
509
# File 'lib/odba/persistable.rb', line 506

def odba_replace_persistables
  clear
  super
end

#odba_restore(collection = []) ⇒ Object



510
511
512
513
514
# File 'lib/odba/persistable.rb', line 510

def odba_restore(collection=[])
  collection.each { |key, val|
    self[key] = val
  }
end

#odba_stubize(obj, opts = {}) ⇒ Object

:nodoc:



531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'lib/odba/persistable.rb', line 531

def odba_stubize(obj, opts={}) # :nodoc:
  return false if(frozen?)
  super
  if opts[:force]
    id = obj.odba_id
    collect! do |item|
      if item.is_a?(ODBA::Persistable) \
        && !item.is_a?(ODBA::Stub) && item.odba_id == id
        ODBA::Stub.new(id, self, obj)
      else
        item
      end
    end
    true
  else
    false
  end
end

#odba_target_idsObject



549
550
551
552
553
554
555
556
557
# File 'lib/odba/persistable.rb', line 549

def odba_target_ids
  ids = super
  self.each { |value|
    if(value.is_a?(ODBA::Persistable))
      ids.push(value.odba_id)
    end
  }
  ids.uniq
end

#odba_unsaved?(snapshot_level = nil) ⇒ Boolean

Returns:

  • (Boolean)


526
527
528
529
530
# File 'lib/odba/persistable.rb', line 526

def odba_unsaved?(snapshot_level = nil)
  super || (snapshot_level.nil? && any? { |val|
    val.is_a?(ODBA::Persistable) && val.odba_unsaved?
  } )
end

#odba_unsaved_neighbors(snapshot_level = nil) ⇒ Object



515
516
517
518
519
520
521
522
523
524
525
# File 'lib/odba/persistable.rb', line 515

def odba_unsaved_neighbors(snapshot_level = nil)
  unsaved = super
  each { |item|
    #odba_extend_enumerable(item)
    if(item.is_a?(ODBA::Persistable) \
      && item.odba_unsaved?(snapshot_level))
      unsaved.push(item)
    end
  }
  unsaved
end

#|(stub) ⇒ Object



164
165
166
# File 'lib/odba/stub.rb', line 164

def |(stub)
  self._odba_union(stub.odba_instance)
end