Sha256: 4cd5c3860d54cebe4bbf8e98e6a219cd4d78dc6b5be0c70b670c87a76fe030ff

Contents?: true

Size: 643 Bytes

Versions: 1

Compression:

Stored size: 643 Bytes

Contents

module StackExchange
  module StackOverflow
    class Base 

      class << self
        def parse_with_class(hash, key, klass)
          case hash[key]
            when Hash 
              hash[key] = klass.new(hash[key])
            when Array
              hash[key] = hash[key].map { |value| klass.new(value) }
          end
        end

        def request(path_pattern, id, options)
          options.merge! :id => id if id
          parse client.request(path_pattern, options)
        end

        def client
          StackExchange::StackOverflow::Client.config unless @client
          @client
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pilha-0.1.6 lib/pilha/stack_overflow/base.rb