Sha256: 68898786ca2797a90d2ac1920e4cf51c600249a52d51de9a963c201757d00d74

Contents?: true

Size: 559 Bytes

Versions: 6

Compression:

Stored size: 559 Bytes

Contents

require 'ostruct'

module Mutaconf

  class Target
    attr_reader :object

    def initialize object
      @object = object
    end

    def set key, value
      if @object.kind_of? Hash
        @object[key.to_sym] = value
      else
        @object.send "#{key}=", value
      end
    end

    def get key
      if @object.kind_of? Hash
        @object[key.to_sym]
      else
        @object.send key.to_sym
      end
    end

    def has? key
      @object.kind_of?(Hash) or @object.kind_of?(OpenStruct) or @object.respond_to?("#{key}=")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutaconf-0.1.1 lib/mutaconf/target.rb
mutaconf-0.1.0 lib/mutaconf/target.rb
mutaconf-0.0.7 lib/mutaconf/target.rb
mutaconf-0.0.6 lib/mutaconf/target.rb
mutaconf-0.0.5 lib/mutaconf/target.rb
mutaconf-0.0.4 lib/mutaconf/target.rb