Sha256: caac6eb85e4a0557f8ede93a65cbd891525e581318e02fde301babdf9ab8bae4

Contents?: true

Size: 886 Bytes

Versions: 5

Compression:

Stored size: 886 Bytes

Contents

module Alf
  module Algebra
    class Project
      include Operator
      include Relational
      include Unary

      signature do |s|
        s.argument :attributes, AttrList, []
        s.option   :allbut,     Boolean,  false, 'Project all but specified attributes?'
      end

      def heading
        @heading ||= operand.heading.project(attributes, allbut)
      end

      def keys
        @keys ||= operand.keys.select{|k|
          k.project(attributes, allbut) == k
        }.if_empty{ Keys[ heading.to_attr_list ] }
      end

      def key_preserving?
        keys.any?{|k| operand.keys.include?(k) }
      end

      def stay_attributes
        allbut ? heading.to_attr_list : attributes
      end

    private

      def _type_check(options)
        no_unknown!(attributes - operand.attr_list)
      end

    end # class Project
  end # module Algebra
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/algebra/operator/project.rb
alf-core-0.16.2 lib/alf/algebra/operator/project.rb
alf-core-0.16.1 lib/alf/algebra/operator/project.rb
alf-core-0.16.0 lib/alf/algebra/operator/project.rb
alf-core-0.15.0 lib/alf/algebra/operator/project.rb