Sha256: 447272aa7ae50798fd599b9142d7158f7852d73ffd418ff70b4375a3e0c89cf4

Contents?: true

Size: 914 Bytes

Versions: 75

Compression:

Stored size: 914 Bytes

Contents

# frozen-string-literal: true
#
# The symbol_as_refinement extension adds a refinement that makes
# Symbol#as return Sequel::SQL::AliasedExpression instances.  It's
# designed as a shortcut so that instead of:
#
#   Sequel[:column].as(:alias) # column AS alias
#
# you can just write:
#   
#   :column.as(:alias) # column AS alias
#
# To load the extension:
#
#   Sequel.extension :symbol_as_refinement
#
# To enable the refinement for the current file:
#
#   using Sequel::SymbolAs
#
# If you would like this extension to be enabled globally instead
# of as a refinement, use the symbol_as extension.
#
# Related module: Sequel::SymbolAs

# :nocov:
raise(Sequel::Error, "Refinements require ruby 2.0.0 or greater") unless RUBY_VERSION >= '2.0.0'
# :nocov:

module Sequel::SymbolAs
  refine Symbol do
    def as(aliaz, columns=nil)
      Sequel::SQL::AliasedExpression.new(self, aliaz, columns)
    end
  end
end

Version data entries

75 entries across 64 versions & 2 rubygems

Version Path
sequel-5.52.0 lib/sequel/extensions/symbol_as_refinement.rb
sequel-5.51.0 lib/sequel/extensions/symbol_as_refinement.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/sequel-5.44.0/lib/sequel/extensions/symbol_as_refinement.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/sequel-5.50.0/lib/sequel/extensions/symbol_as_refinement.rb
sequel-5.50.0 lib/sequel/extensions/symbol_as_refinement.rb
sequel-5.49.0 lib/sequel/extensions/symbol_as_refinement.rb
sequel-5.48.0 lib/sequel/extensions/symbol_as_refinement.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/sequel-5.44.0/lib/sequel/extensions/symbol_as_refinement.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/sequel-5.47.0/lib/sequel/extensions/symbol_as_refinement.rb
sequel-5.47.0 lib/sequel/extensions/symbol_as_refinement.rb
sequel-5.46.0 lib/sequel/extensions/symbol_as_refinement.rb
sequel-5.45.0 lib/sequel/extensions/symbol_as_refinement.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/symbol_as_refinement.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/sequel-5.43.0/lib/sequel/extensions/symbol_as_refinement.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/sequel-5.44.0/lib/sequel/extensions/symbol_as_refinement.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/symbol_as_refinement.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/symbol_as_refinement.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/symbol_as_refinement.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/sequel-5.44.0/lib/sequel/extensions/symbol_as_refinement.rb
sequel-5.44.0 lib/sequel/extensions/symbol_as_refinement.rb