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

#&(other) ⇒ Object



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

def &(other)
  _odba_amp(other.odba_instance)
end

#+(other) ⇒ Object



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

def +(other)
  _odba_plus(other.odba_instance)
end

#-(other) ⇒ Object



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

def -(other)
  _odba_minus(other.odba_instance)
end

#<=>(other) ⇒ Object



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

def <=>(other)
  _odba_weight(other.odba_instance)
end

#==(other) ⇒ Object



169
170
171
# File 'lib/odba/stub.rb', line 169

def ==(other)
  _odba_equal?(other.odba_instance)
end

#_odba_ampObject



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

alias_method :_odba_amp, :&

#_odba_equal?Object



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

alias_method :_odba_equal?, :==

#_odba_minusObject



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

alias_method :_odba_minus, :-

#_odba_plusObject



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

alias_method :_odba_plus, :+

#_odba_unionObject



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

alias_method :_odba_union, :|

#_odba_weightObject



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

alias_method :_odba_weight, :<=>

#odba_collectionObject



512
513
514
515
516
517
518
# File 'lib/odba/persistable.rb', line 512

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

#odba_cut_connection(remove_object) ⇒ Object



520
521
522
523
# File 'lib/odba/persistable.rb', line 520

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

#odba_prefetch?Boolean

Returns:

  • (Boolean)


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

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

#odba_replace!(obj) ⇒ Object

:nodoc:



532
533
534
535
# File 'lib/odba/persistable.rb', line 532

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

#odba_replace_persistablesObject



537
538
539
540
# File 'lib/odba/persistable.rb', line 537

def odba_replace_persistables
  clear
  super
end

#odba_restore(collection = []) ⇒ Object



542
543
544
545
546
# File 'lib/odba/persistable.rb', line 542

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

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

:nodoc:



566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
# File 'lib/odba/persistable.rb', line 566

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



585
586
587
588
589
590
591
592
593
# File 'lib/odba/persistable.rb', line 585

def odba_target_ids
  ids = super
  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)


560
561
562
563
564
# File 'lib/odba/persistable.rb', line 560

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



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

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

#|(other) ⇒ Object



173
174
175
# File 'lib/odba/stub.rb', line 173

def |(other)
  _odba_union(other.odba_instance)
end