Class: Garage::TokenScope::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/garage/token_scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sym, options = {}) ⇒ Scope

Returns a new instance of Scope.



101
102
103
104
105
106
# File 'lib/garage/token_scope.rb', line 101

def initialize(sym, options={})
  @sym = sym
  @access = []
  @hidden = options[:hidden]
  @description = options[:desc]
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



99
100
101
# File 'lib/garage/token_scope.rb', line 99

def description
  @description
end

Instance Method Details

#access(action, klass) ⇒ Object



113
114
115
# File 'lib/garage/token_scope.rb', line 113

def access(action, klass)
  @access << [klass.to_s, action]
end

#accessible_resourcesObject



117
118
119
# File 'lib/garage/token_scope.rb', line 117

def accessible_resources
  @access
end

#hidden?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/garage/token_scope.rb', line 125

def hidden?
  !!@hidden
end

#nameObject Also known as: to_s



108
109
110
# File 'lib/garage/token_scope.rb', line 108

def name
  @sym.to_s
end

#optional?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/garage/token_scope.rb', line 129

def optional?
  @sym != :public && !hidden?
end

#to_symObject



121
122
123
# File 'lib/garage/token_scope.rb', line 121

def to_sym
  @sym
end