Module: Royce::Macros::ClassMethods

Defined in:
lib/royce/macros.rb

Instance Method Summary collapse

Instance Method Details

#royce_roles(roles) ⇒ Object

How a class opts in to roller Pass an array of roles



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/royce/macros.rb', line 9

def royce_roles(roles)
  role_strings = roles.map(&:to_s)

  confirm_roles_exist role_strings

  # Work in singleton class
  # Add a read-only class variable to all classes that call `royce_roles`
  class << self
    attr_reader :available_role_names
  end
  @available_role_names = role_strings

  include Royce::ClassMethods
  include Royce::Methods
end