Sha256: d5e9d9ecbd8c817cf4c60f3f2ed254559d3c466f8a7d570f834c9d1ef46b92eb

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 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.instance
        end
      end

      def initialize(hash)
        @struct = OpenStruct.new hash
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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