Class: Mumukit::Auth::SingleGrant

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

Instance Method Summary collapse

Methods inherited from Grant

#==, #as_json, #hash, #inspect, parse, #to_mumukit_grant

Constructor Details

#initialize(slug) ⇒ SingleGrant

Returns a new instance of SingleGrant.



81
82
83
# File 'lib/mumukit/auth/grant.rb', line 81

def initialize(slug)
  @slug = slug.normalize
end

Instance Method Details

#allows?(resource_slug) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
88
# File 'lib/mumukit/auth/grant.rb', line 85

def allows?(resource_slug)
  resource_slug = resource_slug.to_mumukit_slug.normalize!
  resource_slug.match_first(@slug.first) && resource_slug.match_second(@slug.second)
end

#to_mumukit_slugObject



94
95
96
# File 'lib/mumukit/auth/grant.rb', line 94

def to_mumukit_slug
  @slug
end

#to_sObject



90
91
92
# File 'lib/mumukit/auth/grant.rb', line 90

def to_s
  @slug.to_s
end