Class: Action
- Inherits:
-
Object
- Object
- Action
- Defined in:
- lib/culpa/action.rb
Defined Under Namespace
Classes: RenderNow
Constant Summary collapse
- @@renderers =
{}
Instance Attribute Summary collapse
-
#e ⇒ Object
readonly
Returns the value of attribute e.
-
#r ⇒ Object
readonly
Returns the value of attribute r.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(envelope, request) ⇒ Action
constructor
A new instance of Action.
- #method_missing(sym) ⇒ Object
- #render(options = {}) ⇒ Object
Constructor Details
#initialize(envelope, request) ⇒ Action
Returns a new instance of Action.
21 22 23 24 |
# File 'lib/culpa/action.rb', line 21 def initialize(envelope, request) @e = envelope @r = request end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym) ⇒ Object
26 27 28 |
# File 'lib/culpa/action.rb', line 26 def method_missing(sym) @r.send(sym) end |
Instance Attribute Details
#e ⇒ Object (readonly)
Returns the value of attribute e.
12 13 14 |
# File 'lib/culpa/action.rb', line 12 def e @e end |
#r ⇒ Object (readonly)
Returns the value of attribute r.
12 13 14 |
# File 'lib/culpa/action.rb', line 12 def r @r end |
Class Method Details
.load_renderers ⇒ Object
6 7 8 9 10 |
# File 'lib/culpa/action.rb', line 6 def self.load_renderers Dir[File.join(File.dirname(__FILE__), 'renderers/*.rb')].each do |renderer| @@renderers.merge!(RendererDescriber.new(renderer).result) end end |
Instance Method Details
#render(options = {}) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/culpa/action.rb', line 30 def render( = {}) keyword = .keys.first [:headers] ||= {} raise Culpa::UnknownRenderCall unless @@renderers.include?(keyword) to_render = @@renderers[keyword].call(, @e) raise RenderNow, to_render end |