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
For String and IPAddr instances, wrap them in a cast to inet, to avoid ambiguity issues when calling operator methods.
# 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
Return an expression for the subtraction of the argument from the receiver
# 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
Return the receiver.
# File lib/sequel/extensions/pg_inet_ops.rb, line 118 def pg_inet self end
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
Return an expression for the bitwise NOT of the receiver
# File lib/sequel/extensions/pg_inet_ops.rb, line 123 def ~ self.class.new(super) end
Private Instance Methods
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
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