Sha256: b7bae59a02f7dac761da735edb6157a520c6eca4f1793892ee6299ed6365edfe

Contents?: true

Size: 1.3 KB

Versions: 34

Compression:

Stored size: 1.3 KB

Contents

# frozen-string-literal: true
#
# The s extension adds Sequel::S, a module containing a private #S
# method that calls Sequel.expr.  It's designed as a shortcut so
# that instead of:
#
#   Sequel.expr(:column) + 1
#   # or
#   Sequel.expr{column + 1}
#
# you can just write:
#
#   S(:column) + 1
#   # or
#   S{column + 1}
#
# To load the extension:
#
#   Sequel.extension :s
#
# Then you can include the Sequel::S module into whatever classes or
# objects you care about:
#
#   Sequel::Model.send(:include, Sequel::S)   # available in model instance methods
#   Sequel::Model.extend(Sequel::S)           # available in model class methods
#   Sequel::Dataset.send(:include, Sequel::S) # available in dataset methods
#
# or just into Object if you want it available everywhere:
#
#   Object.send(:include, Sequel::S)
#
# If you are using Ruby 2+, and you would like to use refinements, you
# can use Sequel::S as a refinement, in which case the private #S method
# will be available on all objects while the refinement is active.
#
#   using Sequel::S
#
#   S(:column) + 1
#
# Related module: Sequel::S


# 
module Sequel::S
  private

  # Delegate to Sequel.expr
  def S(*a, &block)
    Sequel.expr(*a, &block)
  end

  # :nocov:
  if RUBY_VERSION >= '2.0.0'
  # :nocov:
    refine Object do
      include Sequel::S
    end
  end
end

Version data entries

34 entries across 23 versions & 2 rubygems

Version Path
sequel-5.51.0 lib/sequel/extensions/s.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/sequel-5.44.0/lib/sequel/extensions/s.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/sequel-5.50.0/lib/sequel/extensions/s.rb
sequel-5.50.0 lib/sequel/extensions/s.rb
sequel-5.49.0 lib/sequel/extensions/s.rb
sequel-5.48.0 lib/sequel/extensions/s.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/sequel-5.44.0/lib/sequel/extensions/s.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/sequel-5.47.0/lib/sequel/extensions/s.rb
sequel-5.47.0 lib/sequel/extensions/s.rb
sequel-5.46.0 lib/sequel/extensions/s.rb
sequel-5.45.0 lib/sequel/extensions/s.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/sequel-5.41.0/lib/sequel/extensions/s.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/sequel-5.43.0/lib/sequel/extensions/s.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/sequel-5.44.0/lib/sequel/extensions/s.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/sequel-5.44.0/lib/sequel/extensions/s.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/sequel-5.38.0/lib/sequel/extensions/s.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/sequel-5.39.0/lib/sequel/extensions/s.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/sequel-5.41.0/lib/sequel/extensions/s.rb
sequel-5.44.0 lib/sequel/extensions/s.rb
sequel-5.43.0 lib/sequel/extensions/s.rb