Sha256: 53741af67c4527c63fb28ac75a532e28ab056629a38c5a5186492f1b629040c5

Contents?: true

Size: 860 Bytes

Versions: 15

Compression:

Stored size: 860 Bytes

Contents

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

15 entries across 15 versions & 1 rubygems

Version Path
torque-postgresql-1.1.8 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-1.1.7 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.0.3 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.0.2 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-1.1.6 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-1.1.5 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.0.1 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-2.0.0 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-1.1.4 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-1.1.3 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-1.1.2 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-1.1.1 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-1.1.0 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-1.0.1 lib/torque/postgresql/arel/nodes.rb
torque-postgresql-1.0.0 lib/torque/postgresql/arel/nodes.rb