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
13 14 15 |
# File 'lib/brainstem/concerns/formattable.rb', line 13 def formatters @formatters ||= ::Brainstem::ApiDocs::FORMATTERS[formatter_type] end |
Instance Method Details
#formatted_as(format, options = {}) ⇒ Object
17 18 19 |
# File 'lib/brainstem/concerns/formattable.rb', line 17 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.
25 26 27 28 29 30 |
# File 'lib/brainstem/concerns/formattable.rb', line 25 def formatter_type self.class.to_s .demodulize .underscore .to_sym end |
#valid_options ⇒ Object
9 10 11 |
# File 'lib/brainstem/concerns/formattable.rb', line 9 def super | [ :formatters ] end |