Sha256: 06dcd806ee0917829648a4e108d423fc139a6588405673042b8e42aff6d7aa30

Contents?: true

Size: 1.01 KB

Versions: 57

Compression:

Stored size: 1.01 KB

Contents

class ParseAtom
  include HTTParty

  # Support Atom along with the default parsers: xml, json, etc.
  class Parser::Atom < HTTParty::Parser
    SupportedFormats.merge!({"application/atom+xml" => :atom})

    protected

    # perform atom parsing on body
    def atom
      body.to_atom
    end
  end

  parser Parser::Atom
end


class OnlyParseAtom
  include HTTParty

  # Only support Atom
  class Parser::OnlyAtom < HTTParty::Parser
    SupportedFormats = {"application/atom+xml" => :atom}

    protected

    # perform atom parsing on body
    def atom
      body.to_atom
    end
  end

  parser Parser::OnlyAtom
end


class SkipParsing
  include HTTParty

  # Parse the response body however you like
  class Parser::Simple < HTTParty::Parser
    def parse
      body
    end
  end

  parser Parser::Simple
end


class AdHocParsing
  include HTTParty
  parser(
    Proc.new do |body, format|
      case format
      when :json
        body.to_json
      when :xml
        body.to_xml
      else
        body
      end
    end
  )
end

Version data entries

57 entries across 56 versions & 8 rubygems

Version Path
alloy_sdk-0.1.0 vendor/bundle/ruby/2.6.0/gems/httparty-0.13.1/examples/custom_parsers.rb
alloy_sdk-0.1.0 vendor/bundle/ruby/3.0.0/gems/httparty-0.13.1/examples/custom_parsers.rb
httsoiree-0.13.3 examples/custom_parsers.rb
allegro_api_client-0.0.9 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/custom_parsers.rb
httparty-0.13.3 examples/custom_parsers.rb
allegro_api_client-0.0.8 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/custom_parsers.rb
allegro_api_client-0.0.7 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/custom_parsers.rb
httparty-0.13.2 examples/custom_parsers.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/httparty-0.13.1/examples/custom_parsers.rb
allegro_api_client-0.0.6 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/custom_parsers.rb
allegro_api_client-0.0.5 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/custom_parsers.rb
allegro_api_client-0.0.4 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/custom_parsers.rb
allegro_api_client-0.0.3 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/custom_parsers.rb
allegro_api_client-0.0.2 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/custom_parsers.rb
allegro_api_client-0.0.1 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/custom_parsers.rb
httsoiree-0.13.1.1 examples/custom_parsers.rb
httsoiree-0.13.1 examples/custom_parsers.rb
httparty-enterprise-edition-0.13.1.1 examples/custom_parsers.rb
httparty-enterprise-edition-0.13.1 examples/custom_parsers.rb
httparty-0.13.1 examples/custom_parsers.rb