Class: KeypathExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/expressions/keypath_expression.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keypath) ⇒ KeypathExpression

Returns a new instance of KeypathExpression.



7
8
9
# File 'lib/expressions/keypath_expression.rb', line 7

def initialize(keypath)
  @keypath = keypath
end

Class Method Details

.parse(array) ⇒ Object



3
4
5
# File 'lib/expressions/keypath_expression.rb', line 3

def self.parse(array)
  self.new(array[1])
end

Instance Method Details

#build_arel(arel_table) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/expressions/keypath_expression.rb', line 11

def build_arel(arel_table)
  result = arel_table
  @keypath.split(".").each do |path|
    result = result[path]
  end
  result
end

#keypathObject



19
20
21
# File 'lib/expressions/keypath_expression.rb', line 19

def keypath
  @keypath
end