Sha256: 15927946ab776c6fefb2eb77e4adb6be98e6341c21d226205430e82ce3f78413

Contents?: true

Size: 891 Bytes

Versions: 31

Compression:

Stored size: 891 Bytes

Contents

# frozen_string_literal: true

module Torque
  module PostgreSQL
    module Arel
      module Nodes

        class Cast < ::Arel::Nodes::Binary
          include ::Arel::Expressions
          include ::Arel::Predications
          include ::Arel::AliasPredication
          include ::Arel::OrderPredications
          include ::Arel::Math

          def initialize(left, right, array = false)
            right = right.to_s
            right << '[]' if array
            super left, right
          end
        end

      end

      ::Arel.define_singleton_method(:array) do |*values, cast: nil|
        values = values.first if values.size.eql?(1) && values.first.is_a?(::Enumerable)
        result = ::Arel::Nodes.build_quoted(values)
        result = result.cast(cast, true) if cast.present?
        result
      end

      ::Arel::Nodes::Function.include(::Arel::Math)
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
torque-postgresql-3.4.1 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.4.5 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.4.0 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.3.3 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.4.4 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.3.2 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.4.3 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.3.1 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.3.0 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.2.2 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.4.2 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.4.1 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.2.1 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.4.0 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.2.0 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.1.0 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.3.0 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.0.1 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.2.4 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-3.0.0 lib/torque/postgresql/arel/nodes.rb