Class: Rql::PathBuilder

Inherits:
Object show all
Defined in:
lib/rql/path_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ PathBuilder

Returns a new instance of PathBuilder.



3
4
5
# File 'lib/rql/path_builder.rb', line 3

def initialize(path = nil)
  @path = path || []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



15
16
17
# File 'lib/rql/path_builder.rb', line 15

def method_missing(name)
  PathBuilder.new(@path.concat([name.to_sym]))
end

Instance Method Details

#to_hObject



7
8
9
10
11
12
13
# File 'lib/rql/path_builder.rb', line 7

def to_h
  path_hash = nil
  @path.reverse_each do |name|
    path_hash = path_hash ? {name.to_sym => path_hash} : name.to_sym
  end
  path_hash
end