# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 52 def primary return @model.send(@class_options.primary) if @class_options.primary.present? @model end
class GlobalRegistry::Bindings::Options::RelationshipInstanceOptions
Public Class Methods
new(type, model)
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 18 def initialize(type, model) @model = model @class_options = model.class.global_registry_relationship(type) end
Public Instance Methods
client_integration_id()
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 40 def client_integration_id option = @class_options.client_integration_id case option when Proc option.call(@model) when Symbol @model.send(option, type) end rescue ArgumentError @model.send(option) end
condition?(cond)
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 127 def condition?(cond) option = @class_options.send(cond) case option when Proc option.call(type, @model) when Symbol @model.send(option, type, @model) else :if != cond end end
exclude()
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 103 def exclude option = @class_options.exclude case option when Proc option.call(type, @model) when Symbol @model.send(option, type) else option end end
fields()
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 115 def fields option = @class_options.fields case option when Proc option.call(type, @model) when Symbol @model.send(option, type) else option end end
id_value()
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 23 def id_value @model.send id_column end
id_value=(value)
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 27 def id_value=(value) @model.send "#{id_column}=", value end
id_value?()
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 31 def id_value? @model.send "#{id_column}?" end
primary()
click to toggle source
primary_id_value()
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 66 def primary_id_value case primary_binding when :entity primary&.global_registry_entity&.id_value else primary&.global_registry_relationship(primary_binding)&.id_value end end
primary_name()
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 75 def primary_name @class_options.primary_name || primary_type end
primary_type()
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 57 def primary_type case primary_binding when :entity primary&.global_registry_entity&.type else primary&.global_registry_relationship(primary_binding)&.type end end
type()
click to toggle source
# File lib/global_registry_bindings/options/relationship_instance_options.rb, line 35 def type t = @class_options.type t.is_a?(Proc) ? t.call(@model) : t end