Sha256: 98aecd69e76e8eb8f75501189e4d302d9adfc550be2a6a4833c716eb6159f277

Contents?: true

Size: 596 Bytes

Versions: 4

Compression:

Stored size: 596 Bytes

Contents

require 'yaml'
require 'json'

module Mobox
  class Config

    def initialize(file)
      @attributes = YAML.load(File.open( file ).read)
    end

    def [] attr_name
      @attributes[attr_name.to_s]
    end

    def []= attr_name, value
      @attributes[attr_name.to_s] = value
    end

    def method_missing name, *args, &block
      if @attributes.has_key? name.to_s
        @attributes[name.to_s]
      else
        super
      end
    end

    def respond_to? name
      @attributes.has_key?(name.to_s) or super
    end
    
    def to_json
      @attributes.to_json
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mobox-0.0.3 lib/mobox/config.rb
mobox-0.0.2 lib/mobox/config.rb
mobox-0.0.1.1 lib/mobox/config.rb
mobox-0.0.1 lib/mobox/config.rb