Sha256: 052d9e7ade7993f312552aa170405569fe54a4b022fd7423c45b1d242271b752

Contents?: true

Size: 728 Bytes

Versions: 3

Compression:

Stored size: 728 Bytes

Contents

module ROM
  class Boot

    class BaseRelationDSL
      attr_reader :env, :name, :repositories, :attributes, :datasets

      def initialize(env, name)
        @env = env
        @name = name
        @attributes = []
      end

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

      def attribute(name)
        attributes << name
      end

      def call(&block)
        instance_exec(&block)

        dataset = repository[name]

        header =
          if attributes.any?
            attributes
          else
            dataset.header
          end

        [name, repository[name], header]
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-0.4.0 lib/rom/boot/base_relation_dsl.rb
rom-0.3.1 lib/rom/boot/base_relation_dsl.rb
rom-0.3.0 lib/rom/boot/base_relation_dsl.rb