Class: LazyAnt::Endpoint
- Inherits:
-
Object
- Object
- LazyAnt::Endpoint
- Extended by:
- Forwardable
- Defined in:
- lib/lazy_ant/endpoint.rb
Overview
Endpoint Definition
(in dsl) api :echo do
get '/echo'
param :hello, default: 'world', required: true, rename: 'SHIT_KEY'
end
client.echo(hello: ‘test’)
> GET ‘/echo?SHIT_KEY=test’
Class Attribute Summary collapse
-
.path ⇒ Object
readonly
Returns the value of attribute path.
-
.verb ⇒ Object
readonly
Returns the value of attribute verb.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(connection) ⇒ Object
-
#initialize(*args) ⇒ Endpoint
constructor
A new instance of Endpoint.
Constructor Details
#initialize(*args) ⇒ Endpoint
Returns a new instance of Endpoint.
18 19 20 21 |
# File 'lib/lazy_ant/endpoint.rb', line 18 def initialize(*args) @query = default_query.merge(args.) @url = build_url(*args) end |
Class Attribute Details
.path ⇒ Object (readonly)
Returns the value of attribute path.
72 73 74 |
# File 'lib/lazy_ant/endpoint.rb', line 72 def path @path end |
.verb ⇒ Object (readonly)
Returns the value of attribute verb.
72 73 74 |
# File 'lib/lazy_ant/endpoint.rb', line 72 def verb @verb end |
Class Method Details
.param(name, options = {}) ⇒ Object
86 87 88 |
# File 'lib/lazy_ant/endpoint.rb', line 86 def param(name, = {}) params[name] = end |
.params ⇒ Object
82 83 84 |
# File 'lib/lazy_ant/endpoint.rb', line 82 def params @params ||= {} end |
Instance Method Details
#execute(connection) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/lazy_ant/endpoint.rb', line 23 def execute(connection) @query = connection.params.merge(@query) validate! connection.send(verb, @url, renamed_query) do |req| req.params.clear if [:put, :post].include?(req.method) end end |