Module: ActsPresentably::InstanceMethods
- Defined in:
- lib/acts_presentably.rb
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #presentable? ⇒ Boolean
- #presenter_class ⇒ Object
- #presenter_key ⇒ Object
Instance Method Details
#as_json(options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/acts_presentably.rb', line 19 def as_json(={}) if && .has_key?(presenter_key) [presenter_key].new(self).as_json() else klass = Module.const_get(presenter_class) return klass.new(self).as_json() if klass.is_a?(Class) super end end |
#presentable? ⇒ Boolean
10 11 12 |
# File 'lib/acts_presentably.rb', line 10 def presentable? true end |
#presenter_class ⇒ Object
13 14 15 |
# File 'lib/acts_presentably.rb', line 13 def presenter_class self.class.name + 'Presenter' end |
#presenter_key ⇒ Object
16 17 18 |
# File 'lib/acts_presentably.rb', line 16 def presenter_key (self.class.name.underscore.downcase + '_presenter').to_sym end |