Class: Octobat::Plaza::Capability
Instance Attribute Summary
#api_key, #parent_obj
Class Method Summary
collapse
Instance Method Summary
collapse
list, set_parent_resource
Methods inherited from APIResource
class_name, #refresh, retrieve
#[], #[]=, #_dump, _load, #as_json, construct_from, #each, #initialize, #inspect, #keys, #refresh_from, #respond_to?, #to_hash, #to_json, #to_s, #values
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Octobat::OctobatObject
Class Method Details
.set_parent_resource(filters) ⇒ Object
50
51
52
|
# File 'lib/octobat/plaza/capability.rb', line 50
def self.set_parent_resource(filters)
@parent_resource = filters.select{|k, v| [:account].include?(k)}
end
|
.url ⇒ Object
44
45
46
47
48
|
# File 'lib/octobat/plaza/capability.rb', line 44
def self.url
if @parent_resource.include?(:account)
"#{Account.url}/#{CGI.escape(@parent_resource[:account])}/capabilities"
end
end
|
Instance Method Details
#ask(params = {}, opts = {}) ⇒ Object
10
11
12
13
|
# File 'lib/octobat/plaza/capability.rb', line 10
def ask(params = {}, opts = {})
response, api_key = Octobat.request(:patch, ask_url, @api_key, params, opts)
refresh_from(response, api_key)
end
|
#ask_url ⇒ Object
40
41
42
|
# File 'lib/octobat/plaza/capability.rb', line 40
def ask_url
"#{parentize_url}/request"
end
|
#parentize_url ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/octobat/plaza/capability.rb', line 24
def parentize_url
if parent_obj.include?(:account)
"#{Account.url}/#{CGI.escape(parent_obj[:account])}/capabilities/#{CGI.escape(id)}"
else
url
end
end
|
#relative_save_url ⇒ Object
34
35
36
37
38
|
# File 'lib/octobat/plaza/capability.rb', line 34
def relative_save_url
if self[:account]
"#{Account.url}/#{CGI.escape(self[:account])}/capabilities"
end
end
|
#save_url ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/octobat/plaza/capability.rb', line 15
def save_url
if self[:id] == nil && self.class.respond_to?(:create)
self.relative_save_url
else
url
end
end
|
#url ⇒ Object
6
7
8
|
# File 'lib/octobat/plaza/capability.rb', line 6
def url
!parent_obj.nil? ? parentize_url : super
end
|