class Praxis::Mapper::ConfigHash

Attributes

hash[R]

Public Class Methods

from(hash={},&block) click to toggle source
# File lib/praxis-mapper/config_hash.rb, line 6
def self.from(hash={},&block)
  self.new(hash,&block)
end
new(hash={},&block) click to toggle source
# File lib/praxis-mapper/config_hash.rb, line 10
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-mapper/config_hash.rb, line 20
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
    if rest.any?
      @hash[name] = [value] + rest
    else
      @hash[name] = value
    end
  end
end
to_hash() click to toggle source
# File lib/praxis-mapper/config_hash.rb, line 15
def to_hash
  self.instance_eval(&@block)
  @hash
end