Class: HttpClientGenerator::ResourcesDefinition
- Inherits:
-
Object
- Object
- HttpClientGenerator::ResourcesDefinition
- Defined in:
- lib/http_client_generator/resources_definition.rb
Overview
:nodoc:
Constant Summary collapse
- DEFAULT_OPTIONS =
{ content_type: :json }.freeze
- HTTP_VERBS =
%i[get post put patch].freeze
Instance Attribute Summary collapse
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
-
#initialize(base, req_plugs = [], resp_plugs = [], timeout = nil) ⇒ ResourcesDefinition
constructor
A new instance of ResourcesDefinition.
- #namespace(_name = nil, &block) ⇒ Object
- #req_plug(plug, *args, only: nil, except: nil, **kwargs) ⇒ Object
- #resp_plug(plug, *args, only: nil, except: nil, **kwargs) ⇒ Object
- #timeout(value = nil, **options) ⇒ Object
Constructor Details
#initialize(base, req_plugs = [], resp_plugs = [], timeout = nil) ⇒ ResourcesDefinition
Returns a new instance of ResourcesDefinition.
13 14 15 16 17 18 19 |
# File 'lib/http_client_generator/resources_definition.rb', line 13 def initialize(base, req_plugs = [], resp_plugs = [], timeout = nil) @base = base @resources = [] @req_plugs = req_plugs @resp_plugs = resp_plugs @timeout = timeout end |
Instance Attribute Details
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
5 6 7 |
# File 'lib/http_client_generator/resources_definition.rb', line 5 def resources @resources end |
Instance Method Details
#namespace(_name = nil, &block) ⇒ Object
39 40 41 42 43 |
# File 'lib/http_client_generator/resources_definition.rb', line 39 def namespace(_name = nil, &block) namespaced_definition = ResourcesDefinition.new(@base, @req_plugs.dup, @resp_plugs.dup, @timeout) namespaced_definition.instance_eval(&block) @resources += namespaced_definition.resources end |
#req_plug(plug, *args, only: nil, except: nil, **kwargs) ⇒ Object
27 28 29 |
# File 'lib/http_client_generator/resources_definition.rb', line 27 def req_plug(plug, *args, only: nil, except: nil, **kwargs) @req_plugs << build_plug_entry(plug, *args, only: only, except: except, **kwargs) end |
#resp_plug(plug, *args, only: nil, except: nil, **kwargs) ⇒ Object
31 32 33 |
# File 'lib/http_client_generator/resources_definition.rb', line 31 def resp_plug(plug, *args, only: nil, except: nil, **kwargs) @resp_plugs << build_plug_entry(plug, *args, only: only, except: except, **kwargs) end |
#timeout(value = nil, **options) ⇒ Object
35 36 37 |
# File 'lib/http_client_generator/resources_definition.rb', line 35 def timeout(value = nil, **) @timeout = TimeoutNormalizer.call(value, **) end |