Class: Cheat::Controllers::Responder::Response
- Inherits:
-
Object
- Object
- Cheat::Controllers::Responder::Response
- Defined in:
- lib/cheat/responder.rb
Constant Summary collapse
- TYPES =
{ :yaml => %w[application/yaml text/yaml], :text => %w[text/plain], :html => %w[text/html */* application/html], :xml => %w[application/xml] }
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
-
#initialize(accept) ⇒ Response
constructor
A new instance of Response.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(accept) ⇒ Response
Returns a new instance of Response.
25 |
# File 'lib/cheat/responder.rb', line 25 def initialize(accept) @accept = accept end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/cheat/responder.rb', line 34 def method_missing(method, *args) if TYPES[method] && @accept =~ Regexp.union(*TYPES[method]) @content_type = TYPES[method].first @body = yield if block_given? end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
24 25 26 |
# File 'lib/cheat/responder.rb', line 24 def body @body end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
24 25 26 |
# File 'lib/cheat/responder.rb', line 24 def content_type @content_type end |