Class: Resourceful::Agent::Mechanize

Inherits:
Base
  • Object
show all
Defined in:
lib/resourceful/agent/mechanize.rb

Constant Summary collapse

ATTRS =
[:agent_alias, :verbose]

Instance Attribute Summary

Attributes inherited from Base

#cache, #expiration, #log_prefix, #logger

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Mechanize

Returns a new instance of Mechanize.



12
13
14
15
16
17
18
19
20
21
# File 'lib/resourceful/agent/mechanize.rb', line 12

def initialize(args={})
  @verbose ||= false
  ATTRS.each { |a| instance_variable_set("@#{a.to_s}", args.delete(a)) if args[a] }
  super(args)
  self.log = yield if block_given?
  @mechanize = ::WWW::Mechanize.new do |obj|
    obj.log = @logger && @verbose ? @logger : nil
    obj.user_agent_alias = @agent_alias unless @agent_alias.nil?
  end
end

Instance Method Details

#get(path, opts = {}, &block) ⇒ Object



23
24
25
# File 'lib/resourceful/agent/mechanize.rb', line 23

def get(path, opts={}, &block)
  call_resource(:get, path, opts, block)
end