Class: PartyResource::Route
- Inherits:
-
Object
- Object
- PartyResource::Route
- Includes:
- Buildable
- Defined in:
- lib/party_resource/route.rb
Constant Summary collapse
- VERBS =
[:get, :post, :put, :delete]
Instance Method Summary collapse
- #call(context, *args) ⇒ Object
- #connector ⇒ Object
-
#initialize(options = {}) ⇒ Route
constructor
A new instance of Route.
- #parsed_response(context, args, options) ⇒ Object
Methods included from Buildable
Constructor Details
#initialize(options = {}) ⇒ Route
Returns a new instance of Route.
9 10 11 |
# File 'lib/party_resource/route.rb', line 9 def initialize( = {}) @options = () end |
Instance Method Details
#call(context, *args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/party_resource/route.rb', line 13 def call(context, *args) = args.pop if args.last.is_a?(Hash) && args.size == expected_args.size + 1 raise ArgumentError, "wrong number of arguments (#{args.size} for #{expected_args.size})" unless expected_args.size == args.size begin builder.call(parsed_response(context, args, ), context, included(context)) rescue Exceptions::Error => e name = e.class.name.split(/::/).last return @options[:rescue][name] if @options[:rescue].has_key?(name) raise end end |
#connector ⇒ Object
29 30 31 |
# File 'lib/party_resource/route.rb', line 29 def connector PartyResource::Connector.lookup(@options[:connector]) end |
#parsed_response(context, args, options) ⇒ Object
25 26 27 |
# File 'lib/party_resource/route.rb', line 25 def parsed_response(context, args, ) connector.fetch(request(context, args, )).parsed_response end |