Class: Roles::Base::RoleStrategyId

Inherits:
Object
  • Object
show all
Defined in:
lib/roles_generic/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strategy_name) ⇒ RoleStrategyId

Returns a new instance of RoleStrategyId.



37
38
39
# File 'lib/roles_generic/base.rb', line 37

def initialize strategy_name
  @name = strategy_name.to_s.underscore.to_sym
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



35
36
37
# File 'lib/roles_generic/base.rb', line 35

def name
  @name
end

Instance Method Details

#multiplicityObject



50
51
52
53
54
55
56
57
# File 'lib/roles_generic/base.rb', line 50

def multiplicity
  @multiplicity ||= case name
  when :many_roles, :role_strings, :roles_mask, :roles_string, :embed_many_roles
    :multi
  when :one_role, :admin_flag, :role_string, :embed_one_role
    :single
  end      
end

#typeObject



41
42
43
44
45
46
47
48
# File 'lib/roles_generic/base.rb', line 41

def type
  @type ||= case name
  when :one_role, :many_roles, :embed_one_role, :embed_many_roles
    :complex
  else
    return :simple if name
  end
end