foreman_pipeline / app / models / foreman_pipeline / authorization / base_model.rb @ be52ca64
1 |
module ForemanPipeline |
---|---|
2 |
module Authorization::BaseModel |
3 |
extend ActiveSupport::Concern |
4 |
|
5 |
include Authorizable
|
6 |
include Katello::Authorization |
7 |
|
8 |
def readable? |
9 |
authorized?(self.normalize_name("read")) |
10 |
end
|
11 |
|
12 |
def editable? |
13 |
authorized?(self.normalize_name("edit")) |
14 |
end
|
15 |
|
16 |
def deletable? |
17 |
authorized?(self.normalize_name("delete")) |
18 |
end
|
19 |
|
20 |
module ClassMethods |
21 |
def readable |
22 |
authorized(normalize_name("view"))
|
23 |
end
|
24 |
|
25 |
# TODO: remove argument
|
26 |
def normalize_name(action_string) |
27 |
(action_string + self.class.name.demodulize.pluralize).underscore.to_sym
|
28 |
end
|
29 |
end
|
30 |
end
|
31 |
end
|