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
77 def initialize(v)
78   case v
79   when ::Sequel::LiteralString
80     # nothing
81   when String, IPAddr
82     v = Sequel.cast(v, :inet)
83   end
84   super
85 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
128 def -(v)
129   case v
130   when Integer
131     self.class.new(super)
132   else
133     Sequel::SQL::NumericExpression.new(:NOOP, super)
134   end
135 end
pg_inet() click to toggle source

Return the receiver.

    # File lib/sequel/extensions/pg_inet_ops.rb
118 def pg_inet
119   self
120 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
138 def set_masklen(v)
139   self.class.new(Sequel::SQL::Function.new(:set_masklen, self, v))
140 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
123 def ~
124   self.class.new(super)
125 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
155 def function(name)
156   Sequel::SQL::Function.new(name, self)
157 end
operator(type, other) click to toggle source

Handle PostgreSQL specific operator types

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