Class: Mumukit::Auth::Grant

Inherits:
Object
  • Object
show all
Defined in:
lib/mumukit/auth/grant.rb

Direct Known Subclasses

AllGrant, FirstPartGrant, SingleGrant

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(pattern) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/mumukit/auth/grant.rb', line 34

def self.parse(pattern)
  case pattern
    when '*' then
      AllGrant.new
    when '*/*' then
      AllGrant.new
    when /(.*)\/\*/
      FirstPartGrant.new($1)
    else
      SingleGrant.new(Slug.parse pattern)
  end
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



20
21
22
# File 'lib/mumukit/auth/grant.rb', line 20

def ==(other)
  other.class == self.class && to_s == other.to_s
end

#as_json(options = {}) ⇒ Object



12
13
14
# File 'lib/mumukit/auth/grant.rb', line 12

def as_json(options={})
  to_s
end

#hashObject



26
27
28
# File 'lib/mumukit/auth/grant.rb', line 26

def hash
  to_s.hash
end

#inspectObject



30
31
32
# File 'lib/mumukit/auth/grant.rb', line 30

def inspect
  "<Mumukit::Auth::Grant #{to_s}>"
end

#to_mumukit_grantObject



16
17
18
# File 'lib/mumukit/auth/grant.rb', line 16

def to_mumukit_grant
  self
end