Class: ArelHash::Sanitizer
- Inherits:
-
Object
- Object
- ArelHash::Sanitizer
- Defined in:
- lib/arel_hash/sanitizer.rb
Instance Method Summary collapse
-
#initialize(predicates = [], attribute_names = []) ⇒ Sanitizer
constructor
A new instance of Sanitizer.
- #sanitize(arel_hash) ⇒ Object
Constructor Details
#initialize(predicates = [], attribute_names = []) ⇒ Sanitizer
Returns a new instance of Sanitizer.
3 4 5 6 |
# File 'lib/arel_hash/sanitizer.rb', line 3 def initialize(predicates = [], attribute_names = []) @predicates = (predicates || []) @attribute_names = (attribute_names || []) end |
Instance Method Details
#sanitize(arel_hash) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/arel_hash/sanitizer.rb', line 8 def sanitize(arel_hash) operator, operand = ArelHash.singleton_tuple!(arel_hash) if operator == :and || operator == :or Hash[operator, operand.map { |o| sanitize(o) }] else sanitize_predication_hash(operator, operand) end end |