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



22
23
24
25
26
27
28
29
30
31
# File 'lib/mumukit/auth/grant.rb', line 22

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

Instance Method Details

#==(other) ⇒ Object



18
19
20
# File 'lib/mumukit/auth/grant.rb', line 18

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

#as_json(options = {}) ⇒ Object



10
11
12
# File 'lib/mumukit/auth/grant.rb', line 10

def as_json(options={})
  to_s
end

#to_mumukit_grantObject



14
15
16
# File 'lib/mumukit/auth/grant.rb', line 14

def to_mumukit_grant
  self
end