Sha256: f873bd76d47eedd97e2b6b9e5029459231bf7c1e54a6d81b32faf09ca72957e9

Contents?: true

Size: 428 Bytes

Versions: 2

Compression:

Stored size: 428 Bytes

Contents

class Mona::Config
  def initialize(attributes = {})
    @attributes = attributes
  end

  def read_attribute(key)
    @attributes[key.to_s]
  end

  def write_attribute(key, value)
    @attributes[key.to_s] = value
  end

  def method_missing(method_name, *_args)
    read_attribute(method_name)
  end

  def to_h
    @attributes.each_with_object({}) do |(k, v), h|
      h[k] = self.class === v ? v.to_h : v
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mona-0.2.3 lib/mona/config.rb
mona-0.2.2 lib/mona/config.rb