Class: CFoundry::V2::ModelMagic::QueryValueHelper::QueryValue

Inherits:
Object
  • Object
show all
Defined in:
lib/cfoundry/v2/model_magic/query_value_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ QueryValue

Returns a new instance of QueryValue.



6
7
8
9
# File 'lib/cfoundry/v2/model_magic/query_value_helper.rb', line 6

def initialize(params)
  self.comparator = params[:comparator] || params[:comp] || ':'
  self.value = params[:value]
end

Instance Attribute Details

#comparatorObject

Returns the value of attribute comparator.



5
6
7
# File 'lib/cfoundry/v2/model_magic/query_value_helper.rb', line 5

def comparator
  @comparator
end

#valueObject

Returns the value of attribute value.



5
6
7
# File 'lib/cfoundry/v2/model_magic/query_value_helper.rb', line 5

def value
  @value
end

Instance Method Details

#comparator_stringObject



15
16
17
18
19
20
21
# File 'lib/cfoundry/v2/model_magic/query_value_helper.rb', line 15

def comparator_string
  if comparator.downcase == 'in' || value.is_a?(Array)
    " IN "
  else
    comparator
  end
end

#to_sObject



11
12
13
# File 'lib/cfoundry/v2/model_magic/query_value_helper.rb', line 11

def to_s
  "#{comparator_string}#{value_string}"
end

#value_stringObject



23
24
25
26
27
28
29
# File 'lib/cfoundry/v2/model_magic/query_value_helper.rb', line 23

def value_string
  if value.is_a? Array
    value.join(",")
  else
    value
  end
end