Module: Relay::Concerns::Roda

Included in:
Pages::Base, Routes::Base
Defined in:
app/concerns/roda.rb

Overview

Shared Roda integration for Relay page and route base classes.

This concern stores the current Roda instance, exposes the request object as ‘r`, and delegates unknown helper calls back to Roda so pages and routes can use methods like `view`, `partial`, `session`, `request`, and `response` without re-defining that plumbing.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kwargs, &block) ⇒ Object

Delegates missing methods to the current Roda instance.

Parameters:

  • name (Symbol)
  • args (Array)
  • kwargs (Hash)

Returns:

  • (Object)


32
33
34
35
36
37
38
# File 'app/concerns/roda.rb', line 32

def method_missing(name, *args, **kwargs, &block)
  if @roda.respond_to?(name)
    @roda.send(name, *args, **kwargs, &block)
  else
    super
  end
end

Instance Method Details

#initialize(roda) ⇒ void

Parameters:



15
16
17
# File 'app/concerns/roda.rb', line 15

def initialize(roda)
  @roda = roda
end

#rRoda::RodaRequest

Returns Alias the request object as ‘r` to match Roda route blocks.

Returns:

  • (Roda::RodaRequest)

    Alias the request object as ‘r` to match Roda route blocks.



22
23
24
# File 'app/concerns/roda.rb', line 22

def r
  @roda.request
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns true when the current Roda instance can respond to a delegated method.

Parameters:

  • name (Symbol)
  • include_private (Boolean) (defaults to: false)

Returns:

  • (Boolean)


46
47
48
# File 'app/concerns/roda.rb', line 46

def respond_to_missing?(name, include_private = false)
  @roda.respond_to?(name) || super
end