Class: Filemaker::Model::Relations::BelongsTo
- Defined in:
- lib/filemaker/model/relations/belongs_to.rb
Instance Attribute Summary
Attributes inherited from Proxy
Instance Method Summary collapse
-
#final_reference_key ⇒ Object
Order: source_key first, reference_key next, then identity all must be findable using ‘to find_field_by_name`.
-
#initialize(owner, name, options) ⇒ BelongsTo
constructor
A new instance of BelongsTo.
- #reference_key ⇒ Object
- #reference_value ⇒ Object
- #source_key ⇒ Object
Methods inherited from Proxy
#method_missing, #respond_to_missing?, #target_class
Constructor Details
#initialize(owner, name, options) ⇒ BelongsTo
Returns a new instance of BelongsTo.
7 8 9 10 |
# File 'lib/filemaker/model/relations/belongs_to.rb', line 7 def initialize(owner, name, ) super(owner, name, ) build_target end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Filemaker::Model::Relations::Proxy
Instance Method Details
#final_reference_key ⇒ Object
Order: source_key first, reference_key next, then identity all must be findable using ‘to find_field_by_name`
26 27 28 29 30 |
# File 'lib/filemaker/model/relations/belongs_to.rb', line 26 def final_reference_key target_class.find_field_by_name(source_key).try(:name) || target_class.find_field_by_name(reference_key).try(:name) || target_class.identity.try(:name) end |
#reference_key ⇒ Object
12 13 14 |
# File 'lib/filemaker/model/relations/belongs_to.rb', line 12 def reference_key .fetch(:reference_key) { "#{@name}_id" } end |
#reference_value ⇒ Object
20 21 22 |
# File 'lib/filemaker/model/relations/belongs_to.rb', line 20 def reference_value owner.public_send(reference_key.to_sym) end |
#source_key ⇒ Object
16 17 18 |
# File 'lib/filemaker/model/relations/belongs_to.rb', line 16 def source_key .fetch(:source_key) { nil } end |