class Praxis::ConfigHash

Attributes

hash[R]

Public Class Methods

from(hash = {}, &block) click to toggle source
# File lib/praxis/config_hash.rb, line 8
def self.from(hash = {}, &block)
  new(hash, &block)
end
new(hash = {}, &block) click to toggle source
# File lib/praxis/config_hash.rb, line 12
def initialize(hash = {}, &block)
  @hash = hash
  @block = block
end

Public Instance Methods

method_missing(name, value, *rest, &block) click to toggle source
# File lib/praxis/config_hash.rb, line 26
def method_missing(name, value, *rest, &block)
  if (existing = @hash[name])
    if block
      existing << [value, block]
    else
      existing << value
      rest.each do |v|
        existing << v
      end
    end
  else
    @hash[name] = if rest.any?
                    [value] + rest
                  else
                    value
                  end
  end
end
respond_to_missing?(_method_name, _include_private = false) click to toggle source
# File lib/praxis/config_hash.rb, line 22
def respond_to_missing?(_method_name, _include_private = false)
  true
end
to_hash() click to toggle source
# File lib/praxis/config_hash.rb, line 17
def to_hash
  instance_eval(&@block)
  @hash
end