Class: Aitch::Namespace
Instance Method Summary collapse
- #config ⇒ Object (also: #configuration)
- #configure {|config| ... } ⇒ Object
- #execute(request_method: nil, url: nil, params: nil, data: nil, body: nil, headers: nil, options: nil, &block) ⇒ Object
- #execute!(*args, &block) ⇒ Object
Instance Method Details
#config ⇒ Object Also known as: configuration
9 10 11 |
# File 'lib/aitch/namespace.rb', line 9 def config @config ||= Configuration.new end |
#configure {|config| ... } ⇒ Object
5 6 7 |
# File 'lib/aitch/namespace.rb', line 5 def configure yield config end |
#execute(request_method: nil, url: nil, params: nil, data: nil, body: nil, headers: nil, options: nil, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/aitch/namespace.rb', line 14 def execute( request_method: nil, url: nil, params: nil, data: nil, body: nil, headers: nil, options: nil, &block ) data = data || params || body || {} headers ||= {} ||= {} if block_given? dsl = DSL.new dsl.instance_eval(&block) args = dsl.to_h else args = { url: url, data: data, headers: headers, options: } end args.merge!( request_method: request_method, options: config.to_h.merge(Utils.symbolize_keys(args[:options])) ) Request.new(args).perform end |
#execute!(*args, &block) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/aitch/namespace.rb', line 49 def execute!(*args, &block) = extract_args!(args) response = execute(**, &block) raise response.error if response.error? response end |