Sha256: 1735eac894f2cc0f03348dbdfe8eb6599a74a0b764c97e0c75ad2cdb0f7a8cba

Contents?: true

Size: 568 Bytes

Versions: 3

Compression:

Stored size: 568 Bytes

Contents

module MongoHQClient
  module Commons
    def method_missing(method, *args)
      attribute = method.to_s
      if (attribute.to_s.end_with? '?')
        attribute = attribute.to_s[0..-2]
      end

      super.method_missing(method, *args) unless json_hash.has_key? attribute

      return json_hash["#{attribute}"]
    end

    def initialize(params = {})
      raise "Invalid json" unless params[:json].is_a? Hash
      @params = params
    end

    protected
    def json_hash
      @params[:json]
    end

    def apikey
      @params[:apikey]
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongohq-client-0.0.4 lib/mongohq-client/commons.rb
mongohq-client-0.0.3 lib/mongohq-client/commons.rb
mongohq-client-0.0.2 lib/mongohq-client/commons.rb