Module: Locomotive::Mongoid::Presenter::ClassMethods
- Defined in:
- lib/locomotive/mongoid/presenter.rb
Instance Method Summary collapse
-
#from_presenter(attributes) ⇒ Object
Initialize an instance of the document by passing attributes calculated by the associated presenter.
-
#presenter_class ⇒ Class
Return the memoized presenter class if it exists.
Instance Method Details
#from_presenter(attributes) ⇒ Object
Initialize an instance of the document by passing attributes calculated by the associated presenter.
61 62 63 64 65 66 |
# File 'lib/locomotive/mongoid/presenter.rb', line 61 def from_presenter(attributes) new.tap do |document| presenter = document.to_presenter presenter.attributes = attributes end end |
#presenter_class ⇒ Class
Return the memoized presenter class if it exists.
48 49 50 51 52 |
# File 'lib/locomotive/mongoid/presenter.rb', line 48 def presenter_class return @presenter_class if @presenter_class _name = "Locomotive::#{name.demodulize}Presenter" @presenter_class = _name.constantize rescue nil end |