Sha256: 78930482d0aea657ba7f79d90fca350e27f5de40183ce1beb668ed283f31aba4

Contents?: true

Size: 527 Bytes

Versions: 2

Compression:

Stored size: 527 Bytes

Contents

class Hash

  # Extends a hash so that it can be used like an object in a template context (e.g. +hash.key+)
  def method_missing(name, *args)
    if name.to_s.ends_with? '='
      name = name.to_s[0..-2]
      self[name] = args[0]
    else
      if self.has_key? name.to_s
        self[name.to_s]
      elsif self.has_key? name.to_sym
        self[name.to_sym]
      else
        super(name,*args)
      end
    end
  end

  # Returns the binding so you can retrieve values from it...
  def get_binding
    binding
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bloggit-1.0.3 lib/bloggit/etc/hash.rb
bloggit-1.0.7 lib/bloggit/etc/hash.rb