Class: Audrey::Node
Overview
Audrey::Node This class defines an object that connects to the database for a single object record.
Direct Known Subclasses
Defined Under Namespace
Classes: Array, Collection, Hash
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#pk ⇒ Object
readonly
Returns the value of attribute pk.
Instance Method Summary collapse
-
#alive? ⇒ Boolean
————————————————————————— alive?.
-
#ancestors ⇒ Object
————————————————————————— ancestors.
-
#delete_object ⇒ Object
————————————————————————— delete_object.
-
#fco ⇒ Object
————————————————————————— fco, isolate.
-
#initialize(p_db, opts = {}) ⇒ Node
constructor
————————————————————————— initialize.
- #isolate ⇒ Object
-
#row ⇒ Object
————————————————————————— row.
Constructor Details
#initialize(p_db, opts = {}) ⇒ Node
initialize
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
# File 'lib/audrey.rb', line 686 def initialize(p_db, opts={}) # param check if not p_db.is_a?(Audrey) raise 'db-param-not-audrey: ' + p_db.class.to_s end # db and engine @db = p_db @engine = @db.engine # hold on to flcass if one was sent @aclass = opts['aclass'] # if a row was sent, cache it and set pk if opts['row'] @row_cache = opts['row'] @pk = @row_cache['pk'] else @pk = opts['pk'] || Audrey::Util.uuid @row_cache = nil end end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
676 677 678 |
# File 'lib/audrey.rb', line 676 def db @db end |
#pk ⇒ Object (readonly)
Returns the value of attribute pk.
675 676 677 |
# File 'lib/audrey.rb', line 675 def pk @pk end |
Instance Method Details
#alive? ⇒ Boolean
alive?
766 767 768 769 |
# File 'lib/audrey.rb', line 766 def alive? # $tm.hrm return @engine.object_exists?(@pk) end |
#ancestors ⇒ Object
ancestors
751 752 753 754 755 756 757 |
# File 'lib/audrey.rb', line 751 def ancestors read_check() @engine.ancestors(@pk) do |row| yield @db.object_from_row(row) end end |
#delete_object ⇒ Object
delete_object
778 779 780 781 |
# File 'lib/audrey.rb', line 778 def delete_object write_check() return @engine.delete_object(@pk) end |
#fco ⇒ Object
fco, isolate
734 735 736 737 |
# File 'lib/audrey.rb', line 734 def fco # $tm.hrm return Audrey::Util.aclass_fco(row['aclass']) end |
#isolate ⇒ Object
739 740 741 742 |
# File 'lib/audrey.rb', line 739 def isolate # $tm.hrm return Audrey::Util.aclass_isolate(row['aclass']) end |
#row ⇒ Object
row
716 717 718 719 720 721 722 723 724 725 |
# File 'lib/audrey.rb', line 716 def row() # $tm.hrm read_check() if not @row_cache @row_cache = @engine.row_by_pk(@pk) end return @row_cache end |