Sha256: 4fd81432ed07970c94ad74f7e9505941e8935a2214a07ede061cc3c14466c428

Contents?: true

Size: 835 Bytes

Versions: 20

Compression:

Stored size: 835 Bytes

Contents

module Bmg
  module Relation
    class Materialized
      include Operator::Unary

      def initialize(operand)
        @operand = operand
        @materialized = nil
      end

      def type
        operand.type
      end

      def type=(type)
        operand.type = type
      end
      protected :type=

    public

      def _count
        _materialize._count
      end

    public

      def each(&bl)
        return to_enum unless block_given?
        _materialize.each(&bl)
      end

      def to_ast
        [ :materizalized, operand ]
      end

      def args
        []
      end

    private

      def _materialize
        return @materialized if @materialized

        @materialized = Relation::InMemory.new(operand.type, operand.to_a)
      end

    end # class Materialized
  end # module Relation
end # module Bmg

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bmg-0.23.3 lib/bmg/relation/materialized.rb
bmg-0.23.2 lib/bmg/relation/materialized.rb
bmg-0.23.1 lib/bmg/relation/materialized.rb
bmg-0.23.0 lib/bmg/relation/materialized.rb
bmg-0.21.5 lib/bmg/relation/materialized.rb
bmg-0.21.4 lib/bmg/relation/materialized.rb
bmg-0.20.5 lib/bmg/relation/materialized.rb
bmg-0.19.3 lib/bmg/relation/materialized.rb
bmg-0.21.3 lib/bmg/relation/materialized.rb
bmg-0.21.2 lib/bmg/relation/materialized.rb
bmg-0.21.0 lib/bmg/relation/materialized.rb
bmg-0.20.4 lib/bmg/relation/materialized.rb
bmg-0.20.2 lib/bmg/relation/materialized.rb
bmg-0.20.1 lib/bmg/relation/materialized.rb
bmg-0.20.0 lib/bmg/relation/materialized.rb
bmg-0.19.2 lib/bmg/relation/materialized.rb
bmg-0.19.1 lib/bmg/relation/materialized.rb
bmg-0.19.0 lib/bmg/relation/materialized.rb
bmg-0.18.15 lib/bmg/relation/materialized.rb
bmg-0.18.14 lib/bmg/relation/materialized.rb