Class: Rql::PathBuilder
Instance Method Summary collapse
-
#initialize(path = nil) ⇒ PathBuilder
constructor
A new instance of PathBuilder.
- #method_missing(name) ⇒ Object
- #to_h ⇒ Object
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_h ⇒ Object
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 |