Class: Presento::Base
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Presento::Base
- Defined in:
- lib/presento/base.rb
Class Method Summary collapse
-
.present(object) ⇒ Object
present the given object and optionally yield it.
- .wrap_all(collection) ⇒ Object (also: present_each)
Instance Method Summary collapse
Class Method Details
.present(object) ⇒ Object
present the given object and optionally yield it
22 23 24 25 26 27 28 |
# File 'lib/presento/base.rb', line 22 def present object if block_given? yield(self.new(object)) else self.new(object) end end |
.wrap_all(collection) ⇒ Object Also known as: present_each
13 14 15 16 17 18 |
# File 'lib/presento/base.rb', line 13 def wrap_all collection collection.each do |object| presenter = self.new(object) yield(presenter) end end |
Instance Method Details
#class ⇒ Object
4 5 6 |
# File 'lib/presento/base.rb', line 4 def class model.class end |
#to_model ⇒ Object
8 9 10 |
# File 'lib/presento/base.rb', line 8 def to_model model end |