Class: CardDB::Record
Overview
Wrapper for DatasetRecord objects
Instance Attribute Summary
Attributes inherited from Resource
#client, #data
Instance Method Summary
collapse
Methods inherited from Resource
#initialize, #key?, #to_h, #to_json
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
741
742
743
744
745
746
747
748
|
# File 'lib/carddb/collection.rb', line 741
def method_missing(method_name, *args, &block)
key = method_name.to_s
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
732
733
734
|
# File 'lib/carddb/collection.rb', line 732
def [](key)
record_data&.[](key.to_s)
end
|
#created_at ⇒ Object
720
721
722
|
# File 'lib/carddb/collection.rb', line 720
def created_at
parse_time(data['createdAt'])
end
|
#dataset ⇒ Object
708
709
710
|
# File 'lib/carddb/collection.rb', line 708
def dataset
data['dataset']
end
|
#dataset_id ⇒ Object
699
700
701
|
# File 'lib/carddb/collection.rb', line 699
def dataset_id
data['datasetId']
end
|
#id ⇒ Object
695
696
697
|
# File 'lib/carddb/collection.rb', line 695
def id
data['id']
end
|
#pricing ⇒ Object
716
717
718
|
# File 'lib/carddb/collection.rb', line 716
def pricing
data['pricing']
end
|
#record_data ⇒ Object
Also known as:
fields
703
704
705
|
# File 'lib/carddb/collection.rb', line 703
def record_data
data['data']
end
|
#resolved_links ⇒ Object
712
713
714
|
# File 'lib/carddb/collection.rb', line 712
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
751
752
753
754
755
756
|
# File 'lib/carddb/collection.rb', line 751
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
724
725
726
|
# File 'lib/carddb/collection.rb', line 724
def updated_at
parse_time(data['updatedAt'])
end
|