Class: Funktional::DelegatingShouldBlock
- Inherits:
-
ShouldBlock
- Object
- ShouldBlock
- Funktional::DelegatingShouldBlock
- Defined in:
- lib/funktional/context/delegating_should_block.rb
Instance Method Summary collapse
- #build_should_name(options, &blk) ⇒ Object
-
#initialize(options, context, &blk) ⇒ DelegatingShouldBlock
constructor
A new instance of DelegatingShouldBlock.
Methods inherited from ShouldBlock
Constructor Details
#initialize(options, context, &blk) ⇒ DelegatingShouldBlock
Returns a new instance of DelegatingShouldBlock.
4 5 6 7 8 |
# File 'lib/funktional/context/delegating_should_block.rb', line 4 def initialize(, context, &blk) @should_name = build_should_name(, &blk) @blk = proc { should(, &blk) } @context = context end |
Instance Method Details
#build_should_name(options, &blk) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/funktional/context/delegating_should_block.rb', line 10 def build_should_name(, &blk) case .keys.first when :render "render the [#{[:render]}] template" when :render_404 "render the [#{[:render_404]}] template with a [404] status code" when :redirect_to "redirect to the [#{[:redirect_to]}] url" when :assign_new "assign a new [#{[:assign_new]}]" when :route, :method args = (.length > 1) ? : .values.first RouteChecker.build(args, &blk).__test_name when :send_email "send an email #{[:send_email].inspect}" else raise NoMethodError, "#{.inspect} is not recognised" end end |