Class: ActiveRecord::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_or.rb

Constant Summary collapse

IS_RAILS3_FLAG =
Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('4.0.0')
IS_RAILS5_FLAG =
Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('5.0.0')
FROM_VALUE_METHOD =
i[from_value from_clause].find{|s| method_defined?(s) }
ASSIGN_FROM_VALUE =
:"#{FROM_VALUE_METHOD}="

Instance Method Summary collapse

Instance Method Details

#or(*other) ⇒ Object



26
27
28
# File 'lib/rails_or.rb', line 26

def or(*other)
  return rails5_or(rails_or_parse_parameter(*other))
end

#or_having(hash) ⇒ Object



64
65
66
# File 'lib/rails_or.rb', line 64

def or_having(hash)
  self.or(rails_or_spwan_relation(:having, hash))
end

#or_not(*args) ⇒ Object

Works in Rails 4+



60
61
62
# File 'lib/rails_or.rb', line 60

def or_not(*args) # Works in Rails 4+
  self.or(klass.where.not(*args))
end

#rails5_orObject



25
# File 'lib/rails_or.rb', line 25

alias_method :rails5_or, :or