Class: WCC::Auth::AccessLevel

Inherits:
Struct
  • Object
show all
Includes:
Comparable
Defined in:
lib/wcc/auth/access_level.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



12
13
14
# File 'lib/wcc/auth/access_level.rb', line 12

def description
  @description
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



12
13
14
# File 'lib/wcc/auth/access_level.rb', line 12

def id
  @id
end

#levelObject

Returns the value of attribute level

Returns:

  • (Object)

    the current value of level



12
13
14
# File 'lib/wcc/auth/access_level.rb', line 12

def level
  @level
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



12
13
14
# File 'lib/wcc/auth/access_level.rb', line 12

def name
  @name
end

#slugObject

Returns the value of attribute slug

Returns:

  • (Object)

    the current value of slug



12
13
14
# File 'lib/wcc/auth/access_level.rb', line 12

def slug
  @slug
end

Class Method Details

.[](index_or_slug, db = ACCESS_LEVELS) ⇒ Object



19
20
21
22
23
24
# File 'lib/wcc/auth/access_level.rb', line 19

def self.[](index_or_slug, db=ACCESS_LEVELS)
  all(db).find do |al|
    al.level.to_s === index_or_slug.to_s ||
      al.slug === index_or_slug.to_s
  end
end

.all(db = ACCESS_LEVELS) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/wcc/auth/access_level.rb', line 26

def self.all(db=ACCESS_LEVELS)
  db.collect do |row|
    new.tap { |access_level|
      row.each { |field, value|
        access_level[field] = value
      }
    }
  end.sort
end

Instance Method Details

#<=>(record) ⇒ Object



15
16
17
# File 'lib/wcc/auth/access_level.rb', line 15

def <=>(record)
  self.level <=> record.level
end