Module: GlobalRegistry::Bindings::Model::Relationship
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/global_registry_bindings/model/relationship.rb
Instance Method Summary collapse
- #relationship_attributes_to_push(type) ⇒ Object
- #relationship_columns_to_push(type) ⇒ Object
- #relationship_value_for_global_registry(name, type) ⇒ Object
Instance Method Details
#relationship_attributes_to_push(type) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/global_registry_bindings/model/relationship.rb', line 9 def relationship_attributes_to_push(type) entity_attributes = relationship_columns_to_push(type).map do |name, t| relationship_value_for_global_registry(name, t) end.compact.to_h unless global_registry_relationship(type).exclude.include?(:client_integration_id) entity_attributes[:client_integration_id] = global_registry_relationship(type).client_integration_id end entity_attributes[:client_updated_at] = updated_at.to_s(:db) if respond_to?(:updated_at) entity_attributes end |
#relationship_columns_to_push(type) ⇒ Object
36 37 38 39 |
# File 'lib/global_registry_bindings/model/relationship.rb', line 36 def relationship_columns_to_push(type) @relationship_columns_to_push ||= {} @relationship_columns_to_push[type] ||= relationship_entity_columns(type) end |
#relationship_value_for_global_registry(name, type) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/global_registry_bindings/model/relationship.rb', line 20 def relationship_value_for_global_registry(name, type) value = send(name) return [name, value] if value.nil? value = case type when :datetime, :date value.to_s(:db) when :boolean value ? "true" : "false" else value.to_s.strip end [name, value] rescue ::NoMethodError nil end |