Sha256: 21b2f8bb43f1d408cfcbb77fd9f2583970e66d58cf5e92b9b2bf5ef0acdb54e0

Contents?: true

Size: 579 Bytes

Versions: 1

Compression:

Stored size: 579 Bytes

Contents

module Duedil
  class Struct
    attr_reader :hash

    def initialize
      @hash = {}
    end

    def [](key)
      @hash[key]
    end

    def []=(key, value)
      @hash[key] = value
    end

    def method_missing(name, *args, &block)
      key = name.to_s.gsub(/_(\w)/) { $1.capitalize }

      if @hash.has_key?(key) && args.empty? && block.nil?
        @hash[key]
      else
        super name, *args, &block
      end
    end

    def respond_to_missing?(name, include_private = false)
      @hash.has_key?(name.to_s.gsub(/_(\w)/) { $1.capitalize })
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
duedil-client-0.0.1 lib/duedil/struct.rb