Class: HaveAPI::Client::Action
- Inherits:
-
Object
- Object
- HaveAPI::Client::Action
- Defined in:
- lib/haveapi/client/action.rb
Instance Method Summary collapse
- #auth? ⇒ Boolean
- #execute(*args) ⇒ Object
- #http_method ⇒ Object
-
#initialize(api, name, spec, args) ⇒ Action
constructor
A new instance of Action.
- #input ⇒ Object
- #layout ⇒ Object
- #name ⇒ Object
- #namespace(src) ⇒ Object
- #output ⇒ Object
- #params ⇒ Object
-
#prepared_url ⇒ Object
Url with resolved parameters.
- #provide_args(*args) ⇒ Object
- #structure ⇒ Object
- #unresolved_args? ⇒ Boolean
- #url ⇒ Object
Constructor Details
#initialize(api, name, spec, args) ⇒ Action
Returns a new instance of Action.
4 5 6 7 8 9 10 |
# File 'lib/haveapi/client/action.rb', line 4 def initialize(api, name, spec, args) @api = api @name = name @spec = spec apply_args(args) end |
Instance Method Details
#auth? ⇒ Boolean
22 23 24 |
# File 'lib/haveapi/client/action.rb', line 22 def auth? @spec[:auth] end |
#execute(*args) ⇒ Object
12 13 14 15 16 |
# File 'lib/haveapi/client/action.rb', line 12 def execute(*args) ret = @api.call(self, *args) @prepared_url = nil ret end |
#http_method ⇒ Object
59 60 61 |
# File 'lib/haveapi/client/action.rb', line 59 def http_method @spec[:method] end |
#input ⇒ Object
26 27 28 |
# File 'lib/haveapi/client/action.rb', line 26 def input @spec[:input] end |
#layout ⇒ Object
34 35 36 |
# File 'lib/haveapi/client/action.rb', line 34 def layout @spec[:output][:layout] end |
#name ⇒ Object
18 19 20 |
# File 'lib/haveapi/client/action.rb', line 18 def name @name end |
#namespace(src) ⇒ Object
42 43 44 |
# File 'lib/haveapi/client/action.rb', line 42 def namespace(src) @spec[src][:namespace] end |
#output ⇒ Object
30 31 32 |
# File 'lib/haveapi/client/action.rb', line 30 def output @spec[:output] end |
#params ⇒ Object
46 47 48 |
# File 'lib/haveapi/client/action.rb', line 46 def params @spec[:output][:parameters] end |
#prepared_url ⇒ Object
Url with resolved parameters.
55 56 57 |
# File 'lib/haveapi/client/action.rb', line 55 def prepared_url @prepared_url || @spec[:url] end |
#provide_args(*args) ⇒ Object
67 68 69 |
# File 'lib/haveapi/client/action.rb', line 67 def provide_args(*args) apply_args(args) end |
#structure ⇒ Object
38 39 40 |
# File 'lib/haveapi/client/action.rb', line 38 def structure @spec[:output][:format] end |
#unresolved_args? ⇒ Boolean
63 64 65 |
# File 'lib/haveapi/client/action.rb', line 63 def unresolved_args? prepared_url =~ /:[a-zA-Z\-_]+/ end |
#url ⇒ Object
50 51 52 |
# File 'lib/haveapi/client/action.rb', line 50 def url @spec[:url] end |