Module: Norairrecord::Util
- Included in:
- Table
- Defined in:
- lib/norairrecord/util.rb
Class Method Summary collapse
- .all_of(*args) ⇒ Object
- .any_of(*args) ⇒ Object
- .field_is_any(field, *args) ⇒ Object
- .mass_sanitize(*args) ⇒ Object
- .none_of(*args) ⇒ Object
- .sanitize(arg) ⇒ Object
Class Method Details
.all_of(*args) ⇒ Object
3 4 5 |
# File 'lib/norairrecord/util.rb', line 3 def all_of(*args) "AND(#{args.join(',')})" end |
.any_of(*args) ⇒ Object
7 8 9 |
# File 'lib/norairrecord/util.rb', line 7 def any_of(*args) "OR(#{args.join(',')})" end |
.field_is_any(field, *args) ⇒ Object
15 16 17 |
# File 'lib/norairrecord/util.rb', line 15 def field_is_any(field, *args) any_of(*args.map { |arg| "#{field}='#{sanitize(arg)}'" }) end |
.mass_sanitize(*args) ⇒ Object
23 24 25 |
# File 'lib/norairrecord/util.rb', line 23 def mass_sanitize(*args) args.map { |arg| sanitize(arg) } end |
.none_of(*args) ⇒ Object
11 12 13 |
# File 'lib/norairrecord/util.rb', line 11 def none_of(*args) "NOT(#{all_of(*args)})" end |
.sanitize(arg) ⇒ Object
19 20 21 |
# File 'lib/norairrecord/util.rb', line 19 def sanitize(arg) arg.gsub(/['"\\]/, '\\\\\0') end |