Sha256: e2f08f4b38854ebb950aa4c93b8f283a759760413304383160d77cb0ec332999

Contents?: true

Size: 410 Bytes

Versions: 1

Compression:

Stored size: 410 Bytes

Contents

class HashWithStructAccess < Hash
  VERSION = "0.0.2"

  def initialize(hash = {})
    hash.each_pair do |key, value|
      self[key] = value.kind_of?(Hash) ? self.class.new(value) : value
    end
    self.freeze
  end

  def method_missing(method_name)
    self[method_name] || self[method_name.to_s] || super
  end

  # Method stub to be overriden by plugins
  def self.compute_path(path)
    path
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hash_with_struct_access-0.0.2 lib/hash_with_struct_access.rb