Class: Shaf::Parser::Base
- Inherits:
-
Object
- Object
- Shaf::Parser::Base
- Defined in:
- lib/shaf/parser/base.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
- .can_handle?(request) ⇒ Boolean
- .inherited(child) ⇒ Object
- .mime_type(type = nil, value = nil) ⇒ Object
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(request:, body:) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(request:, body:) ⇒ Base
Returns a new instance of Base.
27 28 29 30 |
# File 'lib/shaf/parser/base.rb', line 27 def initialize(request:, body:) @request = request @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
25 26 27 |
# File 'lib/shaf/parser/base.rb', line 25 def body @body end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
25 26 27 |
# File 'lib/shaf/parser/base.rb', line 25 def request @request end |
Class Method Details
.can_handle?(request) ⇒ Boolean
19 20 21 |
# File 'lib/shaf/parser/base.rb', line 19 def can_handle?(request) mime_type == request.content_type end |
.inherited(child) ⇒ Object
5 6 7 8 |
# File 'lib/shaf/parser/base.rb', line 5 def inherited(child) Parser.register(child) super end |
.mime_type(type = nil, value = nil) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/shaf/parser/base.rb', line 10 def mime_type(type = nil, value = nil) if type @mime_type = type @mime_type = Sinatra::Base.mime_type(type, value) if type.is_a? Symbol end @mime_type if defined? @mime_type end |
Instance Method Details
#call ⇒ Object
32 33 34 |
# File 'lib/shaf/parser/base.rb', line 32 def call raise NotImplementedError, "#{self.class} must implement #call" end |