Class: RailsAgnosticModels::ArelTranslator::Where

Inherits:
Object
  • Object
show all
Includes:
CollectionConverters
Defined in:
lib/rails_agnostic_models/arel_translator/where.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conditions) ⇒ Where

Returns a new instance of Where.



7
8
9
# File 'lib/rails_agnostic_models/arel_translator/where.rb', line 7

def initialize(conditions)
  @conditions = conditions
end

Instance Attribute Details

#conditionsObject

Returns the value of attribute conditions.



5
6
7
# File 'lib/rails_agnostic_models/arel_translator/where.rb', line 5

def conditions
  @conditions
end

Instance Method Details

#translate!Object



11
12
13
14
15
16
17
# File 'lib/rails_agnostic_models/arel_translator/where.rb', line 11

def translate!
  case self.conditions
  when Hash then return wrap_where hash_without_braches(self.conditions)
  when String then return wrap_where "\"#{self.conditions}\""
  when Array then return wrap_where array_without_brackets(self.conditions)
  end
end