Class: Sequel::Postgres::InetOp
- Inherits:
-
SQL::Wrapper
- Object
- SQL::Expression
- SQL::GenericExpression
- SQL::Wrapper
- Sequel::Postgres::InetOp
- Includes:
- SQL::BitwiseMethods
- Defined in:
- lib/sequel/extensions/pg_inet_ops.rb
Overview
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.
Constant Summary collapse
- OPERATORS =
{ :contained_by_or_equals => ["(".freeze, " <<= ".freeze, ")".freeze].freeze, :contains_or_equals => ["(".freeze, " >>= ".freeze, ")".freeze].freeze, :contains_or_contained_by => ["(".freeze, " && ".freeze, ")".freeze].freeze, }.freeze
Instance Attribute Summary
Attributes inherited from SQL::Wrapper
Instance Method Summary collapse
-
#-(v) ⇒ Object
Return an expression for the subtraction of the argument from the receiver.
-
#initialize(v) ⇒ InetOp
constructor
For String and IPAddr instances, wrap them in a cast to inet, to avoid ambiguity issues when calling operator methods.
-
#pg_inet ⇒ Object
Return the receiver.
-
#set_masklen(v) ⇒ Object
Return an expression for the calling of the set_masklen function with the receiver and the given argument.
-
#~ ⇒ Object
Return an expression for the bitwise NOT of the receiver.
Methods included from SQL::IsDistinctFrom::Methods
Methods included from SQLite::JSONOpMethods
#sqlite_json_op, #sqlite_jsonb_op
Methods included from HStoreOpMethods
Methods included from RangeOpMethods
Methods included from ArrayOpMethods
Methods included from JSONOpMethods
Methods included from PGRowOp::ExpressionMethods
Methods included from SQL::SubscriptMethods
Methods included from SQL::StringMethods
#escaped_ilike, #escaped_like, #ilike, #like
Methods included from SQL::PatternMatchMethods
Methods included from SQL::OrderMethods
Methods included from SQL::NumericMethods
Methods included from SQL::ComplexExpressionMethods
#extract, #sql_boolean, #sql_number, #sql_string
Methods included from SQL::CastMethods
#cast, #cast_numeric, #cast_string
Methods included from SQL::AliasMethods
Methods inherited from SQL::Expression
#==, attr_reader, #clone, #eql?, #hash, inherited, #inspect
Constructor Details
#initialize(v) ⇒ InetOp
For String and IPAddr instances, wrap them in a cast to inet, to avoid ambiguity issues when calling operator methods.
77 78 79 80 81 82 83 84 85 |
# 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 |
Instance Method Details
#-(v) ⇒ Object
Return an expression for the subtraction of the argument from the receiver
128 129 130 131 132 133 134 135 |
# 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 ⇒ Object
Return the receiver.
118 119 120 |
# File 'lib/sequel/extensions/pg_inet_ops.rb', line 118 def pg_inet self end |
#set_masklen(v) ⇒ Object
Return an expression for the calling of the set_masklen function with the receiver and the given argument
138 139 140 |
# 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 |
#~ ⇒ Object
Return an expression for the bitwise NOT of the receiver
123 124 125 |
# File 'lib/sequel/extensions/pg_inet_ops.rb', line 123 def ~ self.class.new(super) end |