:nocov:
Methods
Public Class
Public Instance
Included modules
- Sequel::SQL::AliasMethods
Classes and Modules
Public Instance Aliases
=== | -> | cover? |
Attributes
db_type | [RW] |
The type of this multirange (e.g. ‘int4multirange’). |
Public Class methods
new(ranges, db_type)
Set the array of ranges to delegate to, and the database type.
[show source]
# File lib/sequel/extensions/pg_multirange.rb 266 def initialize(ranges, db_type) 267 super(ranges) 268 @db_type = db_type.to_s 269 end
Public Instance methods
==(other)
Don’t consider multiranges with different database types equal.
[show source]
# File lib/sequel/extensions/pg_multirange.rb 309 def ==(other) 310 return false if PGMultiRange === other && other.db_type != db_type 311 super 312 end
cover?(value)
Return whether the value is inside any of the ranges in the multirange.
[show source]
# File lib/sequel/extensions/pg_multirange.rb 294 def cover?(value) 295 any?{|range| range.cover?(value)} 296 end
eql?(other)
Don’t consider multiranges with different database types equal.
[show source]
# File lib/sequel/extensions/pg_multirange.rb 300 def eql?(other) 301 if PGMultiRange === other 302 return false unless other.db_type == db_type 303 other = other.__getobj__ 304 end 305 __getobj__.eql?(other) 306 end
op()
Wrap the PGRange
instance in an RangeOp
, allowing you to easily use the PostgreSQL range functions and operators with literal ranges.
[show source]
# File lib/sequel/extensions/pg_range_ops.rb 153 def op 154 RangeOp.new(self) 155 end
sequel_auto_param_type(ds)
Allow automatic parameterization.
[show source]
# File lib/sequel/extensions/pg_multirange.rb 341 def sequel_auto_param_type(ds) 342 "::#{db_type}" 343 end
sql_literal_append(ds, sql)
Append the multirange SQL
to the given sql string.
[show source]
# File lib/sequel/extensions/pg_multirange.rb 272 def sql_literal_append(ds, sql) 273 sql << db_type << '(' 274 joiner = nil 275 conversion_meth = nil 276 each do |range| 277 if joiner 278 sql << joiner 279 else 280 joiner = ', ' 281 end 282 283 unless range.is_a?(PGRange) 284 conversion_meth ||= :"typecast_value_#{db_type.sub('multi', '')}" 285 range = ds.db.send(conversion_meth, range) 286 end 287 288 ds.literal_append(sql, range) 289 end 290 sql << ')' 291 end
unquoted_literal(ds)
Return a string containing the unescaped version of the multirange. Separated out for use by the bound argument code.
[show source]
# File lib/sequel/extensions/pg_multirange.rb 316 def unquoted_literal(ds) 317 val = String.new 318 val << "{" 319 320 joiner = nil 321 conversion_meth = nil 322 each do |range| 323 if joiner 324 val << joiner 325 else 326 joiner = ', ' 327 end 328 329 unless range.is_a?(PGRange) 330 conversion_meth ||= :"typecast_value_#{db_type.sub('multi', '')}" 331 range = ds.db.send(conversion_meth, range) 332 end 333 334 val << range.unquoted_literal(ds) 335 end 336 337 val << "}" 338 end