Module: Mountapi::Handler::Behaviour::ClassMethods

Defined in:
lib/mountapi/handler/behaviour.rb

Overview

extend class

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rolesObject (readonly)

Returns the value of attribute roles.



95
96
97
# File 'lib/mountapi/handler/behaviour.rb', line 95

def roles
  @roles
end

Instance Method Details

#allowed_roles(*roles) ⇒ Object



91
92
93
# File 'lib/mountapi/handler/behaviour.rb', line 91

def allowed_roles(*roles)
  @roles = roles
end

#call(params, options = {}) ⇒ Object



82
83
84
85
# File 'lib/mountapi/handler/behaviour.rb', line 82

def call(params, options = {})
  instance = new(params, options)
  instance.role_allowed? ? instance.call : instance.forbidden("Not Allowed")
end

#operation_id(*ids) ⇒ Object



87
88
89
# File 'lib/mountapi/handler/behaviour.rb', line 87

def operation_id(*ids)
  ids.each { |id| Mountapi.handlers.register(id, self) }
end