Class: Slash::Formats::WithSuffix
Instance Attribute Summary collapse
-
#suffix ⇒ Object
readonly
Returns the value of attribute suffix.
Attributes inherited from Format
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(mime, suffix, codec) ⇒ WithSuffix
constructor
A new instance of WithSuffix.
- #prepare_request(options, &block) ⇒ Object
Methods inherited from Format
Constructor Details
#initialize(mime, suffix, codec) ⇒ WithSuffix
Returns a new instance of WithSuffix.
44 45 46 47 |
# File 'lib/slash/formats.rb', line 44 def initialize(mime, suffix, codec) super(mime, codec) @suffix = suffix end |
Instance Attribute Details
#suffix ⇒ Object (readonly)
Returns the value of attribute suffix.
42 43 44 |
# File 'lib/slash/formats.rb', line 42 def suffix @suffix end |
Class Method Details
.json(options = {}) ⇒ Object
60 61 62 63 64 |
# File 'lib/slash/formats.rb', line 60 def self.json( = {}) WithSuffix.new(.fetch(:mime, 'application/json'), .fetch(:suffix, '.json'), .fetch(:codec) { JSON }) end |
.xml(options = {}) ⇒ Object
54 55 56 57 58 |
# File 'lib/slash/formats.rb', line 54 def self.xml( = {}) WithSuffix.new(.fetch(:mime, 'application/xml'), .fetch(:suffix, '.xml'), .fetch(:codec)) end |
Instance Method Details
#prepare_request(options, &block) ⇒ Object
49 50 51 52 |
# File 'lib/slash/formats.rb', line 49 def prepare_request(, &block) [:path] += suffix if suffix super end |