Module: Brainstem::Concerns::Formattable
- Included in:
- ApiDocs::AbstractCollection, ApiDocs::Controller, ApiDocs::Endpoint, ApiDocs::EndpointCollection, ApiDocs::Presenter, ApiDocs::PresenterCollection
- Defined in:
- lib/brainstem/concerns/formattable.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #formatted_as(format, options = {}) ⇒ Object
-
#formatter_type ⇒ Object
Declares the type of formatter that should be used to format an entity of this class.
- #valid_options ⇒ Object
Instance Attribute Details
#formatters ⇒ Object
16 17 18 |
# File 'lib/brainstem/concerns/formattable.rb', line 16 def formatters @formatters ||= ::Brainstem::ApiDocs::FORMATTERS[formatter_type] end |
Instance Method Details
#formatted_as(format, options = {}) ⇒ Object
21 22 23 |
# File 'lib/brainstem/concerns/formattable.rb', line 21 def formatted_as(format, = {}) formatters[format].call(self, ) end |
#formatter_type ⇒ Object
Declares the type of formatter that should be used to format an entity of this class.
30 31 32 33 34 35 |
# File 'lib/brainstem/concerns/formattable.rb', line 30 def formatter_type self.class.to_s .demodulize .underscore .to_sym end |
#valid_options ⇒ Object
11 12 13 |
# File 'lib/brainstem/concerns/formattable.rb', line 11 def super | [ :formatters ] end |