Class: Contextually::Definition
- Inherits:
-
Object
- Object
- Contextually::Definition
- Defined in:
- lib/contextually/definition.rb
Class Method Summary collapse
Instance Method Summary collapse
- #before(name, &block) ⇒ Object
- #before_all(&block) ⇒ Object
- #deny_access(&block) ⇒ Object
- #deny_access_to(name, &block) ⇒ Object
- #group(*roles, &block) ⇒ Object
- #roles(*roles) ⇒ Object
Class Method Details
.define(&block) ⇒ Object
5 6 7 |
# File 'lib/contextually/definition.rb', line 5 def self.define(&block) self.new.instance_eval(&block) end |
Instance Method Details
#before(name, &block) ⇒ Object
18 19 20 |
# File 'lib/contextually/definition.rb', line 18 def before(name, &block) Contextually.roles[name].before = block end |
#before_all(&block) ⇒ Object
22 23 24 |
# File 'lib/contextually/definition.rb', line 22 def before_all(&block) Contextually.before_all = block end |
#deny_access(&block) ⇒ Object
30 31 32 |
# File 'lib/contextually/definition.rb', line 30 def deny_access(&block) Contextually.deny_access_to_all = block end |
#deny_access_to(name, &block) ⇒ Object
26 27 28 |
# File 'lib/contextually/definition.rb', line 26 def deny_access_to(name, &block) Contextually.roles[name].deny_access = block end |
#group(*roles, &block) ⇒ Object
13 14 15 16 |
# File 'lib/contextually/definition.rb', line 13 def group(*roles, &block) as = roles.pop[:as] Contextually.groups[as] = roles end |
#roles(*roles) ⇒ Object
9 10 11 |
# File 'lib/contextually/definition.rb', line 9 def roles(*roles) Contextually.roles = roles.inject({}) { |hash, role| hash[role] = Contextually::Role.new(role); hash } end |