Module: Arel

Defined in:
lib/arel_extensions.rb

Class Method Summary collapse

Class Method Details

.duration(s, expr) ⇒ Object



92
93
94
# File 'lib/arel_extensions.rb', line 92

def self.duration s, expr
  ArelExtensions::Nodes::Duration.new(s.to_s+'i',expr)
end

.falseObject



100
101
102
# File 'lib/arel_extensions.rb', line 100

def self.false
  Arel::Nodes::Equality.new(1,0)
end

.json(*expr) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/arel_extensions.rb', line 80

def self.json *expr
  if expr.length == 1
    ArelExtensions::Nodes::Json.new(expr.first)
  else
    ArelExtensions::Nodes::Json.new(expr)
  end
end

.randObject



72
73
74
# File 'lib/arel_extensions.rb', line 72

def self.rand
  ArelExtensions::Nodes::Rand.new
end

.shorten(s) ⇒ Object



76
77
78
# File 'lib/arel_extensions.rb', line 76

def self.shorten s
  Base64.urlsafe_encode64(Digest::MD5.new.digest(s)).tr('=', '').tr('-', '_')
end

.trueObject



96
97
98
# File 'lib/arel_extensions.rb', line 96

def self.true
  Arel::Nodes::Equality.new(1,1)
end

.when(condition) ⇒ Object



88
89
90
# File 'lib/arel_extensions.rb', line 88

def self.when condition
  ArelExtensions::Nodes::Case.new.when(condition)
end