Sha256: 6b3deabd29d78715ad6fb28ee4f1e85316433461cb417d155aee35f5908bb436

Contents?: true

Size: 858 Bytes

Versions: 1

Compression:

Stored size: 858 Bytes

Contents

module ROM
  class Boot

    class BaseRelationDSL
      attr_reader :env, :name, :header

      def initialize(env, name)
        @env = env
        @name = name
        @header = []
        @repository = nil
      end

      def repository(name = nil)
        if @repository
          @repository
        else
          @repository = env[name]
        end
      end

      def attribute(name)
        header << name
      end

      def call(&block)
        instance_exec(&block)

        dataset =
          if adapter.respond_to?(:dataset)
            adapter.dataset(name, header)
          else
            adapter[name]
          end

        base_header = dataset.respond_to?(:header) ? dataset.header : header

        [name, dataset, base_header]
      end

      private

      def adapter
        repository.adapter
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-0.4.2 lib/rom/boot/base_relation_dsl.rb