Module: Persistence::Object::Complex::Attributes
- Includes:
- CascadingConfiguration::Array::Sorted::Unique, CascadingConfiguration::Hash, CascadingConfiguration::Setting
- Included in:
- ClassInstance, ObjectInstance
- Defined in:
- lib/persistence/object/complex/attributes.rb,
lib/namespaces.rb
Overview
Module managing atomic/non-atomic attribute status to define how objects persist.
Defined Under Namespace
Modules: AttributesArray, AttributesHash, DefaultAtomicNonAtomic Classes: HashToPort
Instance Method Summary collapse
-
#atomic_attribute?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) has atomic reader or writer.
-
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are both atomic readers and writers.
-
#atomic_attribute_accessors ⇒ CompositingHash
Array tracking atomic attribute accessors.
-
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are atomic readers.
-
#atomic_attribute_readers ⇒ CompositingHash
Array tracking atomic attribute readers.
-
#atomic_attribute_status(attribute) ⇒ :reader/:writer/:accessor/nil
Query atomic attribute(s) status (:reader/:writer/:accessor/nil).
-
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are atomic writers.
-
#atomic_attribute_writers ⇒ CompositingHash
Array tracking atomic attribute writers.
-
#atomic_attributes ⇒ CompositingHash
Hash tracking atomic attribute status.
-
#attr_atomic_accessor(attribute_name, ...) ⇒ Object
Declare one or more attributes to persist atomically.
-
#attr_atomic_reader(attribute_name, ...) ⇒ Object
Declare one or more attributes to persist from the database atomically (but not write atomically).
-
#attr_atomic_writer(attribute_name, ...) ⇒ Object
Declare one or more attributes to persist to the database atomically (but not read atomically).
-
#attr_atomic_writer(attribute_name, ...) ⇒ Object
Declare one or more attributes to persist only non-atomically.
-
#attr_non_atomic_reader(attribute_name, ...) ⇒ Object
Declare one or more attributes to read from the database (but not write to it) only non-atomically.
-
#attr_non_atomic_writer(attribute_name, ...) ⇒ Object
Declare one or more attributes to write to the database (but not read from it) only non-atomically.
-
#attrs_atomic! ⇒ Object
Declare all attributes to persist atomically.
-
#attrs_non_atomic! ⇒ Object
Declare all attributes to persist non-atomically.
-
#non_atomic_attribute?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) has non-atomic reader or writer.
-
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are both non-atomic readers and writers.
-
#non_atomic_attribute_accessors ⇒ CompositingHash
Array tracking non-atomic attribute accessors.
-
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are non-atomic readers.
-
#non_atomic_attribute_readers ⇒ CompositingHash
Array tracking non-atomic attribute readers.
-
#non_atomic_attribute_status(attribute) ⇒ :reader/:writer/:accessor/nil
Query non-atomic attribute(s) status (:reader/:writer/:accessor/nil).
-
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are non-atomic writers.
-
#non_atomic_attribute_writers ⇒ CompositingHash
Array tracking non-atomic attribute writers.
-
#non_atomic_attributes ⇒ CompositingHash
Hash tracking non-atomic attribute status.
-
#persistent_attribute?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) has atomic or non-atomic reader or writer.
-
#persistent_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are either atomic or non-atomic readers and writers.
-
#persistent_attribute_accessors ⇒ CompositingHash
Array tracking persistent attribute accessors.
-
#persistent_attribute_reader?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are atomic or non-atomic readers.
-
#persistent_attribute_readers ⇒ CompositingHash
Array tracking persistent attribute readers.
-
#persistent_attribute_status(attribute) ⇒ :reader/:writer/:accessor/nil
Query persistent attribute(s) status (:reader/:writer/:accessor/nil).
-
#persistent_attribute_reader?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are atomic or non-atomic writers.
-
#persistent_attribute_writers ⇒ CompositingHash
Array tracking persistent attribute writers.
-
#persistent_attributes ⇒ CompositingHash
Hash tracking persistent attribute status.
Instance Method Details
#atomic_attribute?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) has atomic reader or writer.
199 200 201 202 203 |
# File 'lib/persistence/object/complex/attributes.rb', line 199 def atomic_attribute?( *attributes ) return atomic_attributes.has_attributes?( *attributes ) end |
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are both atomic readers and writers.
218 219 220 221 222 |
# File 'lib/persistence/object/complex/attributes.rb', line 218 def atomic_attribute_accessor?( *attributes ) return atomic_attribute_accessors.has_attributes?( *attributes ) end |
#atomic_attribute_accessors ⇒ CompositingHash
Array tracking atomic attribute accessors.
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 |
# File 'lib/persistence/object/complex/attributes.rb', line 1137 attr_sorted_unique_array :atomic_attribute_accessors, AttributesArray do #=================# # post_set_hook # #=================# def post_set_hook( index, object, is_insert ) configuration_instance.instance_eval do atomic_attributes.add_without_hooks( object, :accessor ) non_atomic_attributes.subtract_without_hooks( object, :accessor ) non_atomic_attribute_writers.delete_without_hooks( object ) end return object end #====================# # post_delete_hook # #====================# def post_delete_hook( index, object ) configuration_instance.instance_eval do atomic_attributes.delete_without_hooks( object ) atomic_attribute_accessors.delete_without_hooks( object ) atomic_attribute_readers.delete_without_hooks( object ) atomic_attribute_writers.delete_without_hooks( object ) persistent_attributes.delete_without_hooks( object ) persistent_attribute_readers.delete_without_hooks( object ) persistent_attribute_writers.delete_without_hooks( object ) end return object end end |
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are atomic readers.
237 238 239 240 241 |
# File 'lib/persistence/object/complex/attributes.rb', line 237 def atomic_attribute_reader?( *attributes ) return atomic_attribute_readers.has_attributes?( *attributes ) end |
#atomic_attribute_readers ⇒ CompositingHash
Array tracking atomic attribute readers
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 |
# File 'lib/persistence/object/complex/attributes.rb', line 1015 attr_sorted_unique_array :atomic_attribute_readers, AttributesArray do #=================# # post_set_hook # #=================# def post_set_hook( index, object, is_insert ) configuration_instance.instance_eval do atomic_attributes.add_without_hooks( object, :reader ) non_atomic_attributes.subtract_without_hooks( object, :reader ) non_atomic_attribute_readers.delete_without_hooks( object ) end return object end #====================# # post_delete_hook # #====================# def post_delete_hook( index, object ) configuration_instance.instance_eval do atomic_attributes.subtract_without_hooks( object, :reader ) atomic_attribute_accessors.delete( object ) unless non_atomic_attribute_readers.include?( object ) persistent_attributes.subtract_without_hooks( object, :reader ) persistent_attribute_readers.delete_without_hooks( object ) end end return object end end |
#atomic_attribute_status(attribute) ⇒ :reader/:writer/:accessor/nil
Query atomic attribute(s) status (:reader/:writer/:accessor/nil).
273 274 275 276 277 |
# File 'lib/persistence/object/complex/attributes.rb', line 273 def atomic_attribute_status( attribute ) return atomic_attributes[ attribute ] end |
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are atomic writers.
256 257 258 259 260 |
# File 'lib/persistence/object/complex/attributes.rb', line 256 def atomic_attribute_writer?( *attributes ) return atomic_attribute_writers.has_attributes?( *attributes ) end |
#atomic_attribute_writers ⇒ CompositingHash
Array tracking atomic attribute writers.
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 |
# File 'lib/persistence/object/complex/attributes.rb', line 1076 attr_sorted_unique_array :atomic_attribute_writers, AttributesArray do #=================# # post_set_hook # #=================# def post_set_hook( index, object, is_insert ) configuration_instance.instance_eval do atomic_attributes.add_without_hooks( object, :writer ) non_atomic_attributes.subtract_without_hooks( object, :writer ) non_atomic_attribute_writers.delete_without_hooks( object ) end return object end #====================# # post_delete_hook # #====================# def post_delete_hook( index, object ) configuration_instance.instance_eval do atomic_attributes.subtract_without_hooks( object, :writer ) atomic_attribute_accessors.delete( object ) unless non_atomic_attribute_writers.include?( object ) persistent_attributes.subtract_without_hooks( object, :writer ) persistent_attribute_writers.delete_without_hooks( object ) end end return object end end |
#atomic_attributes ⇒ CompositingHash
Hash tracking atomic attribute status
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
# File 'lib/persistence/object/complex/attributes.rb', line 478 attr_hash :atomic_attributes, AttributesHash do #=======================# # update_for_addition # #=======================# def update_for_addition( key, reader_writer_accessor ) configuration_instance.instance_eval do # remove from non-atomic attributes non_atomic_attributes.subtract_without_hooks( key, reader_writer_accessor ) # add to persistent attributes persistent_attributes.add_without_hooks( key, reader_writer_accessor ) non_atomic_attribute_accessors.delete_without_hooks( key ) case reader_writer_accessor when :reader atomic_attribute_readers.push_without_hooks( key ) persistent_attribute_readers.push_without_hooks( key ) non_atomic_attribute_readers.delete_without_hooks( key ) if atomic_attribute_writers.include?( key ) atomic_attribute_accessors.push_without_hooks( key ) end when :writer atomic_attribute_writers.push_without_hooks( key ) persistent_attribute_writers.push_without_hooks( key ) non_atomic_attribute_writers.delete_without_hooks( key ) if atomic_attribute_readers.include?( key ) atomic_attribute_accessors.push_without_hooks( key ) end when :accessor atomic_attribute_readers.push_without_hooks( key ) atomic_attribute_writers.push_without_hooks( key ) atomic_attribute_accessors.push_without_hooks( key ) persistent_attribute_readers.push_without_hooks( key ) persistent_attribute_writers.push_without_hooks( key ) persistent_attribute_accessors.push_without_hooks( key ) non_atomic_attribute_writers.delete_without_hooks( key ) non_atomic_attribute_readers.delete_without_hooks( key ) non_atomic_attribute_accessors.delete_without_hooks( key ) end end end #==========================# # update_for_subtraction # #==========================# def update_for_subtraction( key, reader_writer_accessor ) configuration_instance.instance_eval do # subtract from persistent attributes persistent_attributes.subtract_without_hooks( key, reader_writer_accessor ) atomic_attribute_accessors.delete_without_hooks( key ) case reader_writer_accessor when :reader atomic_attribute_readers.delete_without_hooks( key ) when :writer atomic_attribute_writers.delete_without_hooks( key ) when :accessor atomic_attribute_writers.delete_without_hooks( key ) atomic_attribute_readers.delete_without_hooks( key ) end end end #=======# # []= # #=======# def []=( key, reader_writer_accessor ) if reader_writer_accessor super( key, reader_writer_accessor ) unless @without_hooks configuration_instance.persistent_attributes.add_without_hooks( key, reader_writer_accessor ) case reader_writer_accessor when :reader configuration_instance.instance_eval do atomic_attribute_readers.push_without_hooks( key ) persistent_attribute_readers.push_without_hooks( key ) non_atomic_attributes.subtract_without_hooks( key, :reader ) non_atomic_attribute_readers.delete_without_hooks( key ) non_atomic_attribute_accessors.delete_without_hooks( key ) end when :writer configuration_instance.instance_eval do atomic_attribute_writers.push_without_hooks( key ) persistent_attribute_writers.push_without_hooks( key ) non_atomic_attributes.subtract_without_hooks( key, :writer ) non_atomic_attribute_writers.delete_without_hooks( key ) non_atomic_attribute_accessors.delete_without_hooks( key ) end when :accessor configuration_instance.instance_eval do atomic_attribute_writers.push_without_hooks( key ) atomic_attribute_readers.push_without_hooks( key ) atomic_attribute_accessors.push_without_hooks( key ) persistent_attribute_readers.push_without_hooks( key ) persistent_attribute_writers.push_without_hooks( key ) persistent_attribute_accessors.push_without_hooks( key ) non_atomic_attributes.subtract_without_hooks( key, :accessor ) non_atomic_attribute_readers.delete_without_hooks( key ) non_atomic_attribute_writers.delete_without_hooks( key ) non_atomic_attribute_accessors.delete_without_hooks( key ) end end end else # if we have nil we are actually deleting delete( key ) end return reader_writer_accessor end end |
#attr_atomic_accessor(attribute_name, ...) ⇒ Object
Declare one or more attributes to persist atomically.
24 25 26 27 28 29 30 31 |
# File 'lib/persistence/object/complex/attributes.rb', line 24 def attr_atomic_accessor( *attributes ) attr_atomic_reader( *attributes ) attr_atomic_writer( *attributes ) return self end |
#attr_atomic_reader(attribute_name, ...) ⇒ Object
Declare one or more attributes to persist from the database atomically (but not write atomically).
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/persistence/object/complex/attributes.rb', line 46 def attr_atomic_reader( *attributes ) atomic_attribute_readers.push( *attributes ) attributes.each do |this_attribute| define_reader( this_attribute ) end return self end |
#attr_atomic_writer(attribute_name, ...) ⇒ Object
Declare one or more attributes to persist to the database atomically (but not read atomically).
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/persistence/object/complex/attributes.rb', line 71 def attr_atomic_writer( *attributes ) atomic_attribute_writers.push( *attributes ) attributes.each do |this_attribute| define_writer( this_attribute ) end return self end |
#attr_atomic_writer(attribute_name, ...) ⇒ Object
Declare one or more attributes to persist only non-atomically.
96 97 98 99 100 101 102 103 |
# File 'lib/persistence/object/complex/attributes.rb', line 96 def attr_non_atomic_accessor( *attributes ) attr_non_atomic_reader( *attributes ) attr_non_atomic_writer( *attributes ) return self end |
#attr_non_atomic_reader(attribute_name, ...) ⇒ Object
Declare one or more attributes to read from the database (but not write to it) only non-atomically.
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/persistence/object/complex/attributes.rb', line 118 def attr_non_atomic_reader( *attributes ) non_atomic_attribute_readers.push( *attributes ) attributes.each do |this_attribute| define_reader( this_attribute ) end return self end |
#attr_non_atomic_writer(attribute_name, ...) ⇒ Object
Declare one or more attributes to write to the database (but not read from it) only non-atomically.
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/persistence/object/complex/attributes.rb', line 145 def attr_non_atomic_writer( *attributes ) non_atomic_attribute_writers.push( *attributes ) attributes.each do |this_attribute| define_writer( this_attribute ) end return self end |
#attrs_atomic! ⇒ Object
Declare all attributes to persist atomically.
166 167 168 169 170 |
# File 'lib/persistence/object/complex/attributes.rb', line 166 def attrs_atomic! return attr_atomic_accessor( *non_atomic_attributes.keys ) end |
#attrs_non_atomic! ⇒ Object
Declare all attributes to persist non-atomically.
179 180 181 182 183 184 |
# File 'lib/persistence/object/complex/attributes.rb', line 179 def attrs_non_atomic! # move all declared elements from atomic into non-atomic return attr_non_atomic_accessor( *atomic_attributes ) end |
#non_atomic_attribute?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) has non-atomic reader or writer.
292 293 294 295 296 |
# File 'lib/persistence/object/complex/attributes.rb', line 292 def non_atomic_attribute?( *attributes ) return non_atomic_attributes.has_attributes?( *attributes ) end |
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are both non-atomic readers and writers.
311 312 313 314 315 |
# File 'lib/persistence/object/complex/attributes.rb', line 311 def non_atomic_attribute_accessor?( *attributes ) return non_atomic_attribute_accessors.has_attributes?( *attributes ) end |
#non_atomic_attribute_accessors ⇒ CompositingHash
Array tracking non-atomic attribute accessors.
1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 |
# File 'lib/persistence/object/complex/attributes.rb', line 1319 attr_sorted_unique_array :non_atomic_attribute_accessors, AttributesArray do #=================# # post_set_hook # #=================# def post_set_hook( index, object, is_insert ) configuration_instance.instance_eval do non_atomic_attributes.add_without_hooks( object, :accessor ) atomic_attributes.subtract_without_hooks( object, :accessor ) atomic_attribute_writers.delete_without_hooks( object ) end return object end #====================# # post_delete_hook # #====================# def post_delete_hook( index, object ) configuration_instance.instance_eval do non_atomic_attributes.delete_without_hooks( object ) non_atomic_attribute_accessors.delete_without_hooks( object ) non_atomic_attribute_readers.delete_without_hooks( object ) non_atomic_attribute_writers.delete_without_hooks( object ) persistent_attributes.delete_without_hooks( object ) persistent_attribute_readers.delete_without_hooks( object ) persistent_attribute_writers.delete_without_hooks( object ) end return object end end |
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are non-atomic readers.
330 331 332 333 334 |
# File 'lib/persistence/object/complex/attributes.rb', line 330 def non_atomic_attribute_reader?( *attributes ) return non_atomic_attribute_readers.has_attributes?( *attributes ) end |
#non_atomic_attribute_readers ⇒ CompositingHash
Array tracking non-atomic attribute readers.
1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 |
# File 'lib/persistence/object/complex/attributes.rb', line 1197 attr_sorted_unique_array :non_atomic_attribute_readers, AttributesArray do #=================# # post_set_hook # #=================# def post_set_hook( index, object, is_insert ) configuration_instance.instance_eval do non_atomic_attributes.add_without_hooks( object, :reader ) atomic_attributes.subtract_without_hooks( object, :reader ) atomic_attribute_readers.delete_without_hooks( object ) end return object end #====================# # post_delete_hook # #====================# def post_delete_hook( index, object ) configuration_instance.instance_eval do non_atomic_attributes.subtract_without_hooks( object, :reader ) non_atomic_attribute_accessors.delete( object ) unless atomic_attribute_readers.include?( object ) persistent_attributes.subtract_without_hooks( object, :reader ) persistent_attribute_readers.delete_without_hooks( object ) end end return object end end |
#non_atomic_attribute_status(attribute) ⇒ :reader/:writer/:accessor/nil
Query non-atomic attribute(s) status (:reader/:writer/:accessor/nil).
366 367 368 369 370 |
# File 'lib/persistence/object/complex/attributes.rb', line 366 def non_atomic_attribute_status( attribute ) return non_atomic_attributes[ attribute ] end |
#atomic_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are non-atomic writers.
349 350 351 352 353 |
# File 'lib/persistence/object/complex/attributes.rb', line 349 def non_atomic_attribute_writer?( *attributes ) return non_atomic_attribute_writers.has_attributes?( *attributes ) end |
#non_atomic_attribute_writers ⇒ CompositingHash
Array tracking non-atomic attribute writers.
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 |
# File 'lib/persistence/object/complex/attributes.rb', line 1258 attr_sorted_unique_array :non_atomic_attribute_writers, AttributesArray do #=================# # post_set_hook # #=================# def post_set_hook( index, object, is_insert ) configuration_instance.instance_eval do non_atomic_attributes.add_without_hooks( object, :writer ) atomic_attributes.subtract_without_hooks( object, :writer ) atomic_attribute_writers.delete_without_hooks( object ) end return object end #====================# # post_delete_hook # #====================# def post_delete_hook( index, object ) configuration_instance.instance_eval do non_atomic_attributes.subtract_without_hooks( object, :writer ) non_atomic_attribute_accessors.delete( object ) unless atomic_attribute_writers.include?( object ) persistent_attributes.subtract_without_hooks( object, :writer ) persistent_attribute_writers.delete_without_hooks( object ) end end return object end end |
#non_atomic_attributes ⇒ CompositingHash
Hash tracking non-atomic attribute status
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 |
# File 'lib/persistence/object/complex/attributes.rb', line 662 attr_hash :non_atomic_attributes, AttributesHash do #=======================# # update_for_addition # #=======================# def update_for_addition( key, reader_writer_accessor ) configuration_instance.instance_eval do # remove from non-atomic attributes atomic_attributes.subtract( key, reader_writer_accessor ) # add to persistent attributes persistent_attributes.add_without_hooks( key, reader_writer_accessor ) atomic_attribute_accessors.delete( key ) case reader_writer_accessor when :reader non_atomic_attribute_readers.push( key ) persistent_attribute_readers.push_without_hooks( key ) atomic_attribute_readers.delete( key ) if non_atomic_attribute_writers.include?( key ) non_atomic_attribute_accessors.push_without_hooks( key ) end when :writer non_atomic_attribute_writers.push( key ) persistent_attribute_writers.push_without_hooks( key ) atomic_attribute_writers.delete( key ) if non_atomic_attribute_readers.include?( key ) non_atomic_attribute_accessors.push_without_hooks( key ) end when :accessor non_atomic_attribute_accessors.push( key ) non_atomic_attribute_writers.push( key ) non_atomic_attribute_readers.push( key ) persistent_attribute_readers.push_without_hooks( key ) persistent_attribute_writers.push_without_hooks( key ) persistent_attribute_accessors.push_without_hooks( key ) atomic_attribute_writers.delete( key ) atomic_attribute_readers.delete( key ) end end end #==========================# # update_for_subtraction # #==========================# def update_for_subtraction( key, reader_writer_accessor ) configuration_instance.instance_eval do # subtract from persistent attributes persistent_attributes.subtract_without_hooks( key, reader_writer_accessor ) non_atomic_attribute_accessors.delete_without_hooks( key ) case reader_writer_accessor when :reader non_atomic_attribute_readers.delete_without_hooks( key ) when :writer non_atomic_attribute_writers.delete_without_hooks( key ) when :accessor non_atomic_attribute_writers.delete_without_hooks( key ) non_atomic_attribute_readers.delete_without_hooks( key ) end end end #=======# # []= # #=======# def []=( key, reader_writer_accessor ) if reader_writer_accessor super( key, reader_writer_accessor ) unless @without_hooks configuration_instance.persistent_attributes.add_without_hooks( key, reader_writer_accessor ) case reader_writer_accessor when :reader configuration_instance.instance_eval do non_atomic_attribute_readers.push_without_hooks( key ) persistent_attribute_readers.push_without_hooks( key ) atomic_attributes.subtract_without_hooks( key, :reader ) atomic_attribute_readers.delete_without_hooks( key ) atomic_attribute_accessors.delete_without_hooks( key ) end when :writer configuration_instance.instance_eval do non_atomic_attribute_writers.push_without_hooks( key ) persistent_attribute_writers.push_without_hooks( key ) atomic_attributes.subtract_without_hooks( key, :writer ) atomic_attribute_writers.delete_without_hooks( key ) atomic_attribute_accessors.delete_without_hooks( key ) end when :accessor configuration_instance.instance_eval do non_atomic_attribute_writers.push_without_hooks( key ) non_atomic_attribute_readers.push_without_hooks( key ) non_atomic_attribute_accessors.push_without_hooks( key ) persistent_attribute_readers.push_without_hooks( key ) persistent_attribute_writers.push_without_hooks( key ) persistent_attribute_accessors.push_without_hooks( key ) atomic_attributes.subtract_without_hooks( key, :accessor ) atomic_attribute_readers.delete_without_hooks( key ) atomic_attribute_writers.delete_without_hooks( key ) atomic_attribute_accessors.delete_without_hooks( key ) end end end else # if we have nil we are actually deleting delete( key ) end return reader_writer_accessor end end |
#persistent_attribute?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) has atomic or non-atomic reader or writer.
385 386 387 388 389 |
# File 'lib/persistence/object/complex/attributes.rb', line 385 def persistent_attribute?( *attributes ) return persistent_attributes.has_attributes?( *attributes ) end |
#persistent_attribute_accessor?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are either atomic or non-atomic readers and writers.
404 405 406 407 408 |
# File 'lib/persistence/object/complex/attributes.rb', line 404 def persistent_attribute_accessor?( *attributes ) return persistent_attribute_accessors.has_attributes?( *attributes ) end |
#persistent_attribute_accessors ⇒ CompositingHash
Array tracking persistent attribute accessors.
1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 |
# File 'lib/persistence/object/complex/attributes.rb', line 1635 attr_sorted_unique_array :persistent_attribute_accessors, AttributesArray, DefaultAtomicNonAtomic do #===================# # default_atomic! # #===================# def default_atomic! super unless @without_hooks configuration_instance.instance_eval do persistent_attributes.default_atomic_without_hooks! persistent_attribute_writers.default_atomic_without_hooks! persistent_attribute_readers.default_atomic_without_hooks! end end end #=======================# # default_non_atomic! # #=======================# def default_non_atomic! super unless @without_hooks configuration_instance.instance_eval do persistent_attributes.default_non_atomic_without_hooks! persistent_attribute_writers.default_non_atomic_without_hooks! persistent_attribute_readers.default_non_atomic_without_hooks! end end end #=======# # []= # #=======# def []=( index, reader_writer_accessor ) return_value = nil if @without_hooks or @redirecting_to_atomic_or_non_atomic return_value = super( index, reader_writer_accessor ) else @redirecting_to_atomic_or_non_atomic = true if @default_atomic atomic_attribute_accessors = configuration_instance.atomic_attribute_accessors return_value = atomic_attribute_accessors[ index ] = reader_writer_accessor else non_atomic_attribute_accessors = configuration_instance.non_atomic_attribute_accessors return_value = non_atomic_attribute_accessors[ index ] = reader_writer_accessor end @redirecting_to_atomic_or_non_atomic = false end return return_value end #==========# # insert # #==========# def insert( index, *reader_writer_accessors ) return_value = nil if @without_hooks or @redirecting_to_atomic_or_non_atomic return_value = super( index, *reader_writer_accessors ) else @redirecting_to_atomic_or_non_atomic = true if @default_atomic atomic_attribute_accessors = configuration_instance.atomic_attribute_accessors return_value = atomic_attribute_accessors.insert( index, *reader_writer_accessors ) else non_atomic_attribute_accessors = configuration_instance.non_atomic_attribute_accessors return_value = non_atomic_attribute_accessors.insert( index, *reader_writer_accessors ) end @redirecting_to_atomic_or_non_atomic = false end return return_value end end |
#persistent_attribute_reader?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are atomic or non-atomic readers.
423 424 425 426 427 |
# File 'lib/persistence/object/complex/attributes.rb', line 423 def persistent_attribute_reader?( *attributes ) return persistent_attribute_readers.has_attributes?( *attributes ) end |
#persistent_attribute_readers ⇒ CompositingHash
Array tracking persistent attribute readers.
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 |
# File 'lib/persistence/object/complex/attributes.rb', line 1381 attr_sorted_unique_array :persistent_attribute_readers, AttributesArray, DefaultAtomicNonAtomic do #===================# # default_atomic! # #===================# def default_atomic! super unless @without_hooks configuration_instance.instance_eval do persistent_attributes.default_atomic_without_hooks! persistent_attribute_writers.default_atomic_without_hooks! persistent_attribute_accessors.default_atomic_without_hooks! end end end #=======================# # default_non_atomic! # #=======================# def default_non_atomic! super unless @without_hooks configuration_instance.instance_eval do persistent_attributes.default_non_atomic_without_hooks! persistent_attribute_writers.default_non_atomic_without_hooks! persistent_attribute_accessors.default_non_atomic_without_hooks! end end end #=======# # []= # #=======# def []=( index, reader_writer_accessor ) return_value = nil if @without_hooks or @redirecting_to_atomic_or_non_atomic return_value = super( index, reader_writer_accessor ) else @redirecting_to_atomic_or_non_atomic = true if @default_atomic atomic_attribute_readers = configuration_instance.atomic_attribute_readers return_value = atomic_attribute_readers[ index ] = reader_writer_accessor else non_atomic_attribute_readers = configuration_instance.non_atomic_attribute_readers return_value = non_atomic_attribute_readers[ index ] = reader_writer_accessor end @redirecting_to_atomic_or_non_atomic = false end return return_value end #==========# # insert # #==========# def insert( index, *reader_writer_accessors ) return_value = nil if @without_hooks or @redirecting_to_atomic_or_non_atomic return_value = super( index, *reader_writer_accessors ) else @redirecting_to_atomic_or_non_atomic = true if @default_atomic atomic_attribute_readers = configuration_instance.atomic_attribute_readers return_value = atomic_attribute_readers.insert( index, *reader_writer_accessors ) else non_atomic_attribute_readers = configuration_instance.non_atomic_attribute_readers return_value = non_atomic_attribute_readers.insert( index, *reader_writer_accessors ) end @redirecting_to_atomic_or_non_atomic = false end return return_value end end |
#persistent_attribute_status(attribute) ⇒ :reader/:writer/:accessor/nil
Query persistent attribute(s) status (:reader/:writer/:accessor/nil).
459 460 461 462 463 |
# File 'lib/persistence/object/complex/attributes.rb', line 459 def persistent_attribute_status( attribute ) return persistent_attributes[ attribute ] end |
#persistent_attribute_reader?(attribute_name, ...) ⇒ true, false
Query whether attribute(s) are atomic or non-atomic writers.
442 443 444 445 446 |
# File 'lib/persistence/object/complex/attributes.rb', line 442 def persistent_attribute_writer?( *attributes ) return persistent_attribute_writers.has_attributes?( *attributes ) end |
#persistent_attribute_writers ⇒ CompositingHash
Array tracking persistent attribute writers.
1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 |
# File 'lib/persistence/object/complex/attributes.rb', line 1508 attr_sorted_unique_array :persistent_attribute_writers, AttributesArray, DefaultAtomicNonAtomic do #===================# # default_atomic! # #===================# def default_atomic! super unless @without_hooks configuration_instance.instance_eval do persistent_attributes.default_atomic_without_hooks! persistent_attribute_readers.default_atomic_without_hooks! persistent_attribute_accessors.default_atomic_without_hooks! end end end #=======================# # default_non_atomic! # #=======================# def default_non_atomic! super unless @without_hooks configuration_instance.instance_eval do persistent_attributes.default_non_atomic_without_hooks! persistent_attribute_readers.default_non_atomic_without_hooks! persistent_attribute_accessors.default_non_atomic_without_hooks! end end end #=======# # []= # #=======# def []=( index, reader_writer_accessor ) return_value = nil if @without_hooks or @redirecting_to_atomic_or_non_atomic return_value = super( index, reader_writer_accessor ) else @redirecting_to_atomic_or_non_atomic = true if @default_atomic atomic_attribute_writers = configuration_instance.atomic_attribute_writers return_value = atomic_attribute_writers[ index ] = reader_writer_accessor else non_atomic_attribute_writers = configuration_instance.non_atomic_attribute_writers return_value = non_atomic_attribute_writers[ index ] = reader_writer_accessor end @redirecting_to_atomic_or_non_atomic = false end return return_value end #==========# # insert # #==========# def insert( index, *reader_writer_accessors ) return_value = nil if @without_hooks or @redirecting_to_atomic_or_non_atomic return_value = super( index, *reader_writer_accessors ) else @redirecting_to_atomic_or_non_atomic = true if @default_atomic atomic_attribute_writers = configuration_instance.atomic_attribute_writers return_value = atomic_attribute_writers.insert( index, *reader_writer_accessors ) else non_atomic_attribute_writers = configuration_instance.non_atomic_attribute_writers return_value = non_atomic_attribute_writers.insert( index, *reader_writer_accessors ) end @redirecting_to_atomic_or_non_atomic = false end return return_value end end |
#persistent_attributes ⇒ CompositingHash
Hash tracking persistent attribute status
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 |
# File 'lib/persistence/object/complex/attributes.rb', line 846 attr_hash :persistent_attributes, AttributesHash, DefaultAtomicNonAtomic do #===================# # default_atomic! # #===================# def default_atomic! super unless @without_hooks configuration_instance.instance_eval do persistent_attribute_accessors.default_atomic_without_hooks! persistent_attribute_writers.default_atomic_without_hooks! persistent_attribute_readers.default_atomic_without_hooks! end end end #=======================# # default_non_atomic! # #=======================# def default_non_atomic! super unless @without_hooks configuration_instance.instance_eval do persistent_attribute_accessors.default_non_atomic_without_hooks! persistent_attribute_writers.default_non_atomic_without_hooks! persistent_attribute_readers.default_non_atomic_without_hooks! end end end #=======================# # update_for_addition # #=======================# def update_for_addition( key, reader_writer_accessor ) end #==========================# # update_for_subtraction # #==========================# def update_for_subtraction( key, reader_writer_accessor ) end #=======# # add # #=======# def add( key, reader_writer_accessor ) return_value = nil if @without_hooks or @redirecting_to_atomic_or_non_atomic return_value = super( key, reader_writer_accessor ) else @redirecting_to_atomic_or_non_atomic = true if @default_atomic atomic_attributes = configuration_instance.atomic_attributes return_value = atomic_attributes.add( key, reader_writer_accessor ) else non_atomic_attributes = configuration_instance.non_atomic_attributes return_value = non_atomic_attributes.add( key, reader_writer_accessor ) end @redirecting_to_atomic_or_non_atomic = false end return return_value end #============# # subtract # #============# def subtract( key, reader_writer_accessor ) return_value = nil if @without_hooks or @redirecting_to_atomic_or_non_atomic return_value = super( key, reader_writer_accessor ) else @redirecting_to_atomic_or_non_atomic = true if @default_atomic atomic_attributes = configuration_instance.atomic_attributes return_value = atomic_attributes.subtract( key, reader_writer_accessor ) else non_atomic_attributes = configuration_instance.non_atomic_attributes return_value = non_atomic_attributes.subtract( key, reader_writer_accessor ) end @redirecting_to_atomic_or_non_atomic = false end return return_value end #=======# # []= # #=======# def []=( key, reader_writer_accessor ) return_value = nil if @without_hooks or @redirecting_to_atomic_or_non_atomic return_value = super( key, reader_writer_accessor ) else @redirecting_to_atomic_or_non_atomic = true if @default_atomic return_value = configuration_instance.atomic_attributes[ key ] = reader_writer_accessor else return_value = configuration_instance.non_atomic_attributes[ key ] = reader_writer_accessor end @redirecting_to_atomic_or_non_atomic = false end return return_value end end |