class BabySqueel::Compat::KeyPath

Public Class Methods

evaluate() { |new| ... } click to toggle source
# File lib/baby_squeel/compat.rb, line 12
def self.evaluate(&block)
  if block.arity.zero?
    unwrap new.instance_eval(&block)
  else
    unwrap yield(new)
  end
end
new(*path) click to toggle source
# File lib/baby_squeel/compat.rb, line 30
def initialize(*path)
  @path = path
end
unwrap(path) click to toggle source
# File lib/baby_squeel/compat.rb, line 20
def self.unwrap(path)
  if path.kind_of? self
    path.value
  elsif path.respond_to? :map
    path.map(&method(:unwrap))
  else
    []
  end
end

Public Instance Methods

value() click to toggle source
# File lib/baby_squeel/compat.rb, line 34
def value
  @path.reverse.reduce({}) do |acc, name|
    { name => acc }
  end
end

Private Instance Methods

method_missing(name, *) click to toggle source
# File lib/baby_squeel/compat.rb, line 46
def method_missing(name, *)
  self.class.new(*@path, name)
end
respond_to_missing?(*) click to toggle source
# File lib/baby_squeel/compat.rb, line 42
def respond_to_missing?(*)
  true
end