Class: HaveAPI::Client::Action
- Inherits:
-
Object
- Object
- HaveAPI::Client::Action
- Defined in:
- lib/haveapi/client/action.rb
Instance Attribute Summary collapse
-
#resource_path ⇒ Object
Returns the value of attribute resource_path.
Instance Method Summary collapse
- #aliases(include_name = false) ⇒ Object
- #auth? ⇒ Boolean
- #description ⇒ Object
- #examples ⇒ Object
- #execute(*args) ⇒ Object
- #help ⇒ Object
- #http_method ⇒ Object
-
#initialize(api, name, spec, args) ⇒ Action
constructor
A new instance of Action.
- #input ⇒ Object
- #input_layout ⇒ Object
- #input_params ⇒ Object
- #name ⇒ Object
- #namespace(src) ⇒ Object
- #output ⇒ Object
- #output_layout ⇒ Object
- #param_description(dir, name) ⇒ Object
- #params ⇒ Object
- #prepared_help ⇒ Object
-
#prepared_url ⇒ Object
Url with resolved parameters.
- #provide_args(*args) ⇒ Object
- #provide_url(url, help) ⇒ Object
- #structure ⇒ Object
- #unresolved_args? ⇒ Boolean
- #update_description(spec) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(api, name, spec, args) ⇒ Action
Returns a new instance of Action.
6 7 8 9 10 11 12 |
# File 'lib/haveapi/client/action.rb', line 6 def initialize(api, name, spec, args) @api = api @name = name @spec = spec apply_args(args) end |
Instance Attribute Details
#resource_path ⇒ Object
Returns the value of attribute resource_path.
4 5 6 |
# File 'lib/haveapi/client/action.rb', line 4 def resource_path @resource_path end |
Instance Method Details
#aliases(include_name = false) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/haveapi/client/action.rb', line 29 def aliases(include_name = false) if include_name [@name] + @spec[:aliases] else @spec[:aliases] end end |
#auth? ⇒ Boolean
25 26 27 |
# File 'lib/haveapi/client/action.rb', line 25 def auth? @spec[:auth] end |
#description ⇒ Object
37 38 39 |
# File 'lib/haveapi/client/action.rb', line 37 def description @spec[:description] end |
#examples ⇒ Object
65 66 67 |
# File 'lib/haveapi/client/action.rb', line 65 def examples @spec[:examples] end |
#execute(*args) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/haveapi/client/action.rb', line 14 def execute(*args) ret = @api.call(self, *args) @prepared_url = nil @prepared_help = nil ret end |
#help ⇒ Object
85 86 87 |
# File 'lib/haveapi/client/action.rb', line 85 def help @spec[:help] end |
#http_method ⇒ Object
98 99 100 |
# File 'lib/haveapi/client/action.rb', line 98 def http_method @spec[:method] end |
#input ⇒ Object
41 42 43 |
# File 'lib/haveapi/client/action.rb', line 41 def input @spec[:input] end |
#input_layout ⇒ Object
49 50 51 |
# File 'lib/haveapi/client/action.rb', line 49 def input_layout @spec[:input][:layout].to_sym end |
#input_params ⇒ Object
69 70 71 |
# File 'lib/haveapi/client/action.rb', line 69 def input_params @spec[:input][:parameters] end |
#name ⇒ Object
21 22 23 |
# File 'lib/haveapi/client/action.rb', line 21 def name @name end |
#namespace(src) ⇒ Object
61 62 63 |
# File 'lib/haveapi/client/action.rb', line 61 def namespace(src) @spec[src][:namespace] end |
#output ⇒ Object
45 46 47 |
# File 'lib/haveapi/client/action.rb', line 45 def output @spec[:output] end |
#output_layout ⇒ Object
53 54 55 |
# File 'lib/haveapi/client/action.rb', line 53 def output_layout @spec[:output][:layout].to_sym end |
#param_description(dir, name) ⇒ Object
77 78 79 |
# File 'lib/haveapi/client/action.rb', line 77 def param_description(dir, name) @spec[dir][:parameters][name] end |
#params ⇒ Object
73 74 75 |
# File 'lib/haveapi/client/action.rb', line 73 def params @spec[:output][:parameters] end |
#prepared_help ⇒ Object
94 95 96 |
# File 'lib/haveapi/client/action.rb', line 94 def prepared_help @prepared_help || @spec[:help] end |
#prepared_url ⇒ Object
Url with resolved parameters.
90 91 92 |
# File 'lib/haveapi/client/action.rb', line 90 def prepared_url @prepared_url || @spec[:url] end |
#provide_args(*args) ⇒ Object
106 107 108 |
# File 'lib/haveapi/client/action.rb', line 106 def provide_args(*args) apply_args(args) end |
#provide_url(url, help) ⇒ Object
110 111 112 113 |
# File 'lib/haveapi/client/action.rb', line 110 def provide_url(url, help) @prepared_url = url @prepared_help = help end |
#structure ⇒ Object
57 58 59 |
# File 'lib/haveapi/client/action.rb', line 57 def structure @spec[:output][:format] end |
#unresolved_args? ⇒ Boolean
102 103 104 |
# File 'lib/haveapi/client/action.rb', line 102 def unresolved_args? prepared_url =~ /:[a-zA-Z\-_]+/ end |
#update_description(spec) ⇒ Object
115 116 117 |
# File 'lib/haveapi/client/action.rb', line 115 def update_description(spec) @spec = spec end |
#url ⇒ Object
81 82 83 |
# File 'lib/haveapi/client/action.rb', line 81 def url @spec[:url] end |