Class: CardDB::Record
Overview
Wrapper for DatasetRecord objects
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#[](key) ⇒ Object?
Access record data fields directly via bracket notation.
- #created_at ⇒ Object
- #dataset ⇒ Object
- #dataset_id ⇒ Object
- #id ⇒ Object
-
#method_missing(method_name, *args, &block) ⇒ Object
Access record data fields directly via method calls.
- #record_data ⇒ Object (also: #fields)
- #resolved_links ⇒ Object
-
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Support respond_to? for dynamic field access.
- #updated_at ⇒ Object
Methods inherited from Resource
#initialize, #key?, #to_h, #to_json
Constructor Details
This class inherits a constructor from CardDB::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
Access record data fields directly via method calls
731 732 733 734 735 736 737 738 |
# File 'lib/carddb/collection.rb', line 731 def method_missing(method_name, *args, &block) key = method_name.to_s # Only handle reader methods (no args, no block, no assignment) return record_data&.[](key) if args.empty? && block.nil? && !key.end_with?('=') super end |
Instance Method Details
#[](key) ⇒ Object?
Access record data fields directly via bracket notation
722 723 724 |
# File 'lib/carddb/collection.rb', line 722 def [](key) record_data&.[](key.to_s) end |
#created_at ⇒ Object
710 711 712 |
# File 'lib/carddb/collection.rb', line 710 def created_at parse_time(data['createdAt']) end |
#dataset ⇒ Object
702 703 704 |
# File 'lib/carddb/collection.rb', line 702 def dataset data['dataset'] end |
#dataset_id ⇒ Object
693 694 695 |
# File 'lib/carddb/collection.rb', line 693 def dataset_id data['datasetId'] end |
#id ⇒ Object
689 690 691 |
# File 'lib/carddb/collection.rb', line 689 def id data['id'] end |
#record_data ⇒ Object Also known as: fields
697 698 699 |
# File 'lib/carddb/collection.rb', line 697 def record_data data['data'] end |
#resolved_links ⇒ Object
706 707 708 |
# File 'lib/carddb/collection.rb', line 706 def resolved_links @resolved_links ||= parse_resolved_links end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Support respond_to? for dynamic field access
741 742 743 744 745 746 |
# File 'lib/carddb/collection.rb', line 741 def respond_to_missing?(method_name, include_private = false) key = method_name.to_s return true if record_data&.key?(key) super end |
#updated_at ⇒ Object
714 715 716 |
# File 'lib/carddb/collection.rb', line 714 def updated_at parse_time(data['updatedAt']) end |