Class: TypeScopes::Boolean
Constant Summary
Constants inherited
from TypeScopes
VERSION
Class Method Summary
collapse
Methods inherited from TypeScopes
append_scope, inject, support?
Class Method Details
.inject_for_column(model, name) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/type_scopes/boolean.rb', line 6
def self.inject_for_column(model, name)
append_scope(model, :"#{name}", lambda { where(name => true) })
prefix, suffix = /\A(has|is|was)_(.+)\z/.match(name).to_a[1..2]
if prefix && suffix
append_scope(model, :"#{prefix}_not_#{suffix}", lambda { where(name => false) })
else
append_scope(model, :"not_#{name}", lambda { where(name => false) })
end
end
|
.types ⇒ Object
2
3
4
|
# File 'lib/type_scopes/boolean.rb', line 2
def self.types
["bool", "boolean", "tinyint(1)"].freeze
end
|