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.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(envelope, request, session) ⇒ Action
constructor
A new instance of Action.
- #method_missing(sym) ⇒ Object
- #render(options = {}) ⇒ Object
Constructor Details
#initialize(envelope, request, session) ⇒ Action
Returns a new instance of Action.
29 30 31 32 33 |
# File 'lib/culpa/action.rb', line 29 def initialize(envelope, request, session) @e = envelope @r = request @session = session end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym) ⇒ Object
35 36 37 |
# File 'lib/culpa/action.rb', line 35 def method_missing(sym) @r.send(sym) end |
Instance Attribute Details
#e ⇒ Object (readonly)
Returns the value of attribute e.
20 21 22 |
# File 'lib/culpa/action.rb', line 20 def e @e end |
#r ⇒ Object (readonly)
Returns the value of attribute r.
20 21 22 |
# File 'lib/culpa/action.rb', line 20 def r @r end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
20 21 22 |
# File 'lib/culpa/action.rb', line 20 def session @session end |
Class Method Details
.add_renderer(filepath) ⇒ Object
10 11 12 |
# File 'lib/culpa/action.rb', line 10 def self.add_renderer(filepath) @@renderers.merge!(RendererDescriber.new(filepath).result) end |
.load_renderers ⇒ Object
14 15 16 17 18 |
# File 'lib/culpa/action.rb', line 14 def self.load_renderers Dir[File.join(File.dirname(__FILE__), 'renderers/*.rb')].each do |renderer| @@renderers.merge!(RendererDescriber.new(renderer).result) end end |
.renderers_list ⇒ Object
6 7 8 |
# File 'lib/culpa/action.rb', line 6 def self.renderers_list @@renderers end |
Instance Method Details
#render(options = {}) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/culpa/action.rb', line 39 def render( = {}) keyword = .keys.first [:headers] ||= {} raise Culpa::UnknownRenderCall unless @@renderers.include?(keyword) to_render = @@renderers[keyword].call(, @e) raise RenderNow, to_render end |