Class: Ilike::ArelTemplate
- Inherits:
-
Object
- Object
- Ilike::ArelTemplate
- Defined in:
- lib/ilike/arel_template.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(arr) ⇒ ArelTemplate
constructor
A new instance of ArelTemplate.
- #template(value) ⇒ Object
Constructor Details
#initialize(arr) ⇒ ArelTemplate
Returns a new instance of ArelTemplate.
5 6 7 |
# File 'lib/ilike/arel_template.rb', line 5 def initialize(arr) @field, @values = arr end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
3 4 5 |
# File 'lib/ilike/arel_template.rb', line 3 def field @field end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
3 4 5 |
# File 'lib/ilike/arel_template.rb', line 3 def values @values end |
Instance Method Details
#build ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/ilike/arel_template.rb', line 9 def build if Array === values values.map {|value| template(value)} else template(values) end end |
#template(value) ⇒ Object
17 18 19 |
# File 'lib/ilike/arel_template.rb', line 17 def template(value) "(arel_table[:#{field}].matches('#{value}'))" end |