class Sequel::Postgres::InetOp

The InetOp class is a simple container for a single object that defines methods that yield Sequel expression objects representing PostgreSQL inet operators and functions.

Most methods in this class are defined via metaprogramming, see the pg_inet_ops extension documentation for details on the API.

Constants

OPERATORS

Public Class Methods

new(v) click to toggle source

For String and IPAddr instances, wrap them in a cast to inet, to avoid ambiguity issues when calling operator methods.

Calls superclass method Sequel::SQL::Wrapper.new
# File lib/sequel/extensions/pg_inet_ops.rb, line 77
def initialize(v)
  case v
  when ::Sequel::LiteralString
    # nothing
  when String, IPAddr
    v = Sequel.cast(v, :inet)
  end
  super
end

Public Instance Methods

-(v) click to toggle source

Return an expression for the subtraction of the argument from the receiver

Calls superclass method
# File lib/sequel/extensions/pg_inet_ops.rb, line 128
def -(v)
  case v
  when Integer
    self.class.new(super)
  else
    Sequel::SQL::NumericExpression.new(:NOOP, super)
  end
end
pg_inet() click to toggle source

Return the receiver.

# File lib/sequel/extensions/pg_inet_ops.rb, line 118
def pg_inet
  self
end
set_masklen(v) click to toggle source

Return an expression for the calling of the #set_masklen function with the receiver and the given argument

# File lib/sequel/extensions/pg_inet_ops.rb, line 138
def set_masklen(v)
  self.class.new(Sequel::SQL::Function.new(:set_masklen, self, v))
end
~() click to toggle source

Return an expression for the bitwise NOT of the receiver

Calls superclass method Sequel::SQL::BitwiseMethods#~
# File lib/sequel/extensions/pg_inet_ops.rb, line 123
def ~
  self.class.new(super)
end

Private Instance Methods

function(name) click to toggle source

Return a function called with the receiver.

# File lib/sequel/extensions/pg_inet_ops.rb, line 155
def function(name)
  Sequel::SQL::Function.new(name, self)
end
operator(type, other) click to toggle source

Handle PostgreSQL specific operator types

# File lib/sequel/extensions/pg_inet_ops.rb, line 150
def operator(type, other)
  Sequel::SQL::PlaceholderLiteralString.new(OPERATORS[type], [value, other])
end