: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 276 def initialize(ranges, db_type) 277 super(ranges) 278 @db_type = db_type.to_s 279 end
Public Instance methods
==(other)
Don’t consider multiranges with different database types equal.
[show source]
# File lib/sequel/extensions/pg_multirange.rb 319 def ==(other) 320 return false if PGMultiRange === other && other.db_type != db_type 321 super 322 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 304 def cover?(value) 305 any?{|range| range.cover?(value)} 306 end
eql?(other)
Don’t consider multiranges with different database types equal.
[show source]
# File lib/sequel/extensions/pg_multirange.rb 310 def eql?(other) 311 if PGMultiRange === other 312 return false unless other.db_type == db_type 313 other = other.__getobj__ 314 end 315 __getobj__.eql?(other) 316 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
sql_literal_append(ds, sql)
Append the multirange SQL
to the given sql string.
[show source]
# File lib/sequel/extensions/pg_multirange.rb 282 def sql_literal_append(ds, sql) 283 sql << db_type << '(' 284 joiner = nil 285 conversion_meth = nil 286 each do |range| 287 if joiner 288 sql << joiner 289 else 290 joiner = ', ' 291 end 292 293 unless range.is_a?(PGRange) 294 conversion_meth ||= :"typecast_value_#{db_type.sub('multi', '')}" 295 range = ds.db.send(conversion_meth, range) 296 end 297 298 ds.literal_append(sql, range) 299 end 300 sql << ')' 301 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 326 def unquoted_literal(ds) 327 val = String.new 328 val << "{" 329 330 joiner = nil 331 conversion_meth = nil 332 each do |range| 333 if joiner 334 val << joiner 335 else 336 joiner = ', ' 337 end 338 339 unless range.is_a?(PGRange) 340 conversion_meth ||= :"typecast_value_#{db_type.sub('multi', '')}" 341 range = ds.db.send(conversion_meth, range) 342 end 343 344 val << range.unquoted_literal(ds) 345 end 346 347 val << "}" 348 end