Sha256: 0a9bc80815361310067329fe302dd564c7a2ef8f01587bdb223a41f5c88ffcd6

Contents?: true

Size: 1.48 KB

Versions: 5

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module GlobalRegistry #:nodoc:
  module Bindings #:nodoc:
    module Options
      class InstanceOptions
        delegate :id_column,
                 :mdm_id_column,
                 :mdm_timeout,
                 :type,
                 :push_on,
                 :parent_association,
                 :related_association,
                 :exclude_fields,
                 :extra_fields,
                 :parent_class,
                 :related_class,
                 :parent_type,
                 :related_type,
                 :parent_relationship_name,
                 :related_relationship_name,
                 :parent_is_self?,
                 :mdm_worker_class_name,
                 to: :@class_options

        def initialize(model)
          @model = model
          @class_options = model.class.global_registry
        end

        def id_value
          @model.send id_column
        end

        def id_value=(value)
          @model.send "#{id_column}=", value
        end

        def id_value?
          @model.send "#{id_column}?"
        end

        def parent
          @model.send(parent_association) if parent_association.present?
        end

        def related
          @model.send(related_association) if related_association.present?
        end

        def parent_id_value
          parent&.global_registry&.id_value
        end

        def related_id_value
          related&.global_registry&.id_value
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
global-registry-bindings-0.0.5 lib/global_registry_bindings/options/instance_options.rb
global-registry-bindings-0.0.4 lib/global_registry_bindings/options/instance_options.rb
global-registry-bindings-0.0.3 lib/global_registry_bindings/options/instance_options.rb
global-registry-bindings-0.0.2 lib/global_registry_bindings/options/instance_options.rb
global-registry-bindings-0.0.1 lib/global_registry_bindings/options/instance_options.rb