Module: Puffer::User::Base

Extended by:
ActiveSupport::Concern
Included in:
ActiveRecord, Mongoid
Defined in:
lib/puffer/backends/models/user/base.rb

Instance Method Summary collapse

Instance Method Details

#has_role?(role) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/puffer/backends/models/user/base.rb', line 25

def has_role? role
  roles_array.include?(role.to_s)
end

#roles=(value) ⇒ Object



16
17
18
19
# File 'lib/puffer/backends/models/user/base.rb', line 16

def roles= value
  value = value.split(',').map(&:strip).map(&:presence) if value.is_a?(String)
  write_attribute(:roles, value.join(', '))
end

#roles_arrayObject



21
22
23
# File 'lib/puffer/backends/models/user/base.rb', line 21

def roles_array
  roles.to_s.split(',').map(&:strip).map(&:presence)
end