Class: Foreman::AccessControl::Permission

Inherits:
Object
  • Object
show all
Defined in:
lib/foreman/access_control.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, hash, options) ⇒ Permission


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/foreman/access_control.rb', line 91

def initialize(name, hash, options)
  @name = name
  @actions = []
  @public = options[:public] || false
  @require = options[:require]
  @security_block = options[:security_block]
  hash.each do |controller, actions|
    if actions.is_a? Array
      @actions << actions.collect {|action| "#{controller}/#{action}"}
    else
      @actions << "#{controller}/#{actions}"
    end
  end
  @actions.flatten!
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions


89
90
91
# File 'lib/foreman/access_control.rb', line 89

def actions
  @actions
end

#nameObject (readonly)

Returns the value of attribute name


89
90
91
# File 'lib/foreman/access_control.rb', line 89

def name
  @name
end

#security_blockObject (readonly)

Returns the value of attribute security_block


89
90
91
# File 'lib/foreman/access_control.rb', line 89

def security_block
  @security_block
end

Instance Method Details

#public?Boolean


107
108
109
# File 'lib/foreman/access_control.rb', line 107

def public?
  @public
end

#require_loggedin?Boolean


115
116
117
# File 'lib/foreman/access_control.rb', line 115

def require_loggedin?
  @require && (@require == :member || @require == :loggedin)
end

#require_member?Boolean


111
112
113
# File 'lib/foreman/access_control.rb', line 111

def require_member?
  @require && @require == :member
end