Project

General

Profile

Download (623 Bytes) Statistics
| Branch: | Tag: | Revision:

foreman_pipeline / app / models / foreman_pipeline / authorization / base_model.rb @ 720671b8

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
      def normalize_name(action_string)
26
        (action_string + self.class.name.demodulize.pluralize).underscore.to_sym
27
      end
28
    end
29
  end
30
end