lib/global_registry_bindings/model/relationship.rb in global-registry-bindings-0.6.2 vs lib/global_registry_bindings/model/relationship.rb in global-registry-bindings-0.6.3

- old
+ new

@@ -1,10 +1,10 @@ # frozen_string_literal: true -module GlobalRegistry #:nodoc: - module Bindings #:nodoc: - module Model #:nodoc: +module GlobalRegistry # :nodoc: + module Bindings # :nodoc: + module Model # :nodoc: module Relationship extend ActiveSupport::Concern def relationship_attributes_to_push(type) entity_attributes = relationship_columns_to_push(type).map do |name, t| @@ -19,17 +19,17 @@ 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 + when :datetime, :date + value.to_s(:db) + when :boolean + value ? "true" : "false" + else + value.to_s.strip + end [name, value] rescue ::NoMethodError nil end @@ -39,28 +39,28 @@ end protected def normalize_relationship_column_type(type, name) - if type.to_s == 'text' + if type.to_s == "text" :string - elsif name.ends_with?('_id') + elsif name.ends_with?("_id") :uuid else type end end def relationship_entity_columns(type) if global_registry_relationship(type).include_all_columns? self.class - .columns - .collect do |c| - { c.name.underscore.to_sym => normalize_relationship_column_type(c.type, c.name) } + .columns + .collect do |c| + {c.name.underscore.to_sym => normalize_relationship_column_type(c.type, c.name)} end # rubocop:disable Style/MultilineBlockChain - .reduce(&:merge) - .reject { |k, _v| global_registry_relationship(type).exclude.include? k } - .merge(global_registry_relationship(type).fields) + .reduce(&:merge) + .except(*global_registry_relationship(type).exclude) + .merge(global_registry_relationship(type).fields) else global_registry_relationship(type).fields || {} end end end