Module: Rollability
- Extended by:
- Configuration
- Defined in:
- lib/rollability.rb,
lib/rollability/version.rb,
lib/rollability/client_service.rb,
lib/rollability/rollability_events.rb
Defined Under Namespace
Classes: ClientService, RollabiltyEvents
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
- #can(capability, secret, app_name) ⇒ Object
- #clean_cache ⇒ Object
-
#method_missing(name, *args, &block) ⇒ Object
def fetch_permission(secret, app_name, action, url) request = Typhoeus::Request.new(“#url/#action.json”, method: :get, params: {app_name: app_name }, headers: { Accept: “application/json”, Cookie: “advaya=#CGI.escape(secret)” } ) response = request.on_complete do |response| if response.success? return response.body elsif response.timed_out? return ‘[]’ elsif response.code == 0 return ‘[]’ else # Received a non-successful http response.
Methods included from Configuration
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
def fetch_permission(secret, app_name, action, url) request = Typhoeus::Request.new(“#url/#action.json”,
method: :get,
params: {app_name: app_name },
headers: { Accept: "application/json",
Cookie: "advaya=#{CGI.escape(secret)}"
}
)
response = request.on_complete do |response|
if response.success? return response.body elsif response.timed_out? return ‘[]’ elsif response.code == 0 return ‘[]’ else # Received a non-successful http response. return ‘[]’ end end
request.run
end
64 65 66 67 68 69 70 71 72 |
# File 'lib/rollability.rb', line 64 def method_missing(name, *args, &block) if name =~ /can/i method_name, capability = name.to_s.split('_', 2) capability.slice! '?' can(capability, args[0], args[1]) else super end end |
Instance Method Details
#can(capability, secret, app_name) ⇒ Object
19 20 21 |
# File 'lib/rollability.rb', line 19 def can(capability, secret, app_name) all_capablility = Rollability.client_sevice.check_from_store(secret, app_name, self) end |
#clean_cache ⇒ Object
23 24 25 |
# File 'lib/rollability.rb', line 23 def clean_cache Rollability.client_sevice.clean_cache(self) end |