Sha256: 383156a048d03e8bbf3823b383e2dae0a84dee8c6e834edc773ed6effb127d08

Contents?: true

Size: 1.76 KB

Versions: 9

Compression:

Stored size: 1.76 KB

Contents

module ActiveData
  module Model
    module Associations
      module PersistenceAdapters
        class Base
          attr_reader :data_source, :primary_key, :scope_proc

          def initialize(data_source, primary_key, scope_proc = nil)
            @data_source = data_source
            @primary_key = primary_key
            @scope_proc = scope_proc
          end

          def build(_attributes)
            raise NotImplementedError, 'Should be implemented in inhereted adapter. Build new instance of data object by attributes'
          end

          def persist(_object, *)
            raise NotImplementedError, 'Should be implemented in inhereted adapter. Build new instance of data object by attributes'
          end

          def scope(_owner, _source)
            raise NotImplementedError, 'Should be implemented in inhereted adapter. Better to be Enumerable'
          end

          def find_one(owner, identificator)
            scope(owner, identificator).first
          end

          def find_all(owner, identificators)
            scope(owner, identificators).to_a
          end

          def identify(_object)
            raise NotImplementedError, 'Should be implemented in inhereted adapter. Field to be used as primary_key for object'
          end

          def data_type
            raise NotImplementedError, 'Should be implemented in inhereted adapter. Type of data object for type_check'
          end

          def primary_key_type
            raise NotImplementedError, 'Should be implemented in inhereted adapter. Ruby data type'
          end

          def referenced_proxy
            raise NotImplementedError, 'Should be implemented in inhereted adapter. Object to manage proxying of methods to scope.'
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
active_data-1.2.0 lib/active_data/model/associations/persistence_adapters/base.rb
active_data-1.1.7 lib/active_data/model/associations/persistence_adapters/base.rb
active_data-1.1.6 lib/active_data/model/associations/persistence_adapters/base.rb
active_data-1.1.5 lib/active_data/model/associations/persistence_adapters/base.rb
active_data-1.1.4 lib/active_data/model/associations/persistence_adapters/base.rb
active_data-1.1.3 lib/active_data/model/associations/persistence_adapters/base.rb
active_data-1.1.2 lib/active_data/model/associations/persistence_adapters/base.rb
active_data-1.1.1 lib/active_data/model/associations/persistence_adapters/base.rb
active_data-1.1.0 lib/active_data/model/associations/persistence_adapters/base.rb