Module: Contextually::ExampleExtension
- Defined in:
- lib/contextually/example_extension.rb
Instance Method Summary collapse
- #as(*args, &block) ⇒ Object
- #deny_access_to(*args) ⇒ Object
- #only_allow_access_to(*args) ⇒ Object
- #only_as(*args, &block) ⇒ Object
Instance Method Details
#as(*args, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/contextually/example_extension.rb', line 8 def as(*args, &block) roles, params = extract_params(args) roles.each do |role| context "as #{role}" do before(&Contextually.before_all) if Contextually.before_all before(&Contextually.before(role)) describe(params.dup, &block) end end end |
#deny_access_to(*args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/contextually/example_extension.rb', line 19 def deny_access_to(*args) roles, params = extract_params(args) roles.each do |role| block = Contextually.deny_access(role) if block context "as #{role}" do before(&Contextually.before_all) if Contextually.before_all before(&Contextually.before(role)) describe(params.dup, &block) end else raise Contextually::UndefinedContext, "don't know how to deny access to a #{role}" end end end |
#only_allow_access_to(*args) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/contextually/example_extension.rb', line 35 def only_allow_access_to(*args) roles, params = extract_params(args) deny_params = Contextually.roles.keys - roles deny_params.push(params) deny_access_to(*deny_params) end |
#only_as(*args, &block) ⇒ Object
3 4 5 6 |
# File 'lib/contextually/example_extension.rb', line 3 def only_as(*args, &block) as(*args, &block) only_allow_access_to(*args) end |