Class: Bumbleworks::Api::Presenter
- Inherits:
-
Object
- Object
- Bumbleworks::Api::Presenter
- Defined in:
- lib/bumbleworks/api/lib/presenter.rb
Direct Known Subclasses
EntityClassPresenter, EntityPresenter, ErrorPresenter, ExpressionPresenter, ProcessPresenter, TaskPresenter, TrackerPresenter, WorkerPresenter
Instance Attribute Summary collapse
-
#presented ⇒ Object
readonly
Returns the value of attribute presented.
Class Method Summary collapse
Instance Method Summary collapse
- #in_collection? ⇒ Boolean
-
#initialize(presented, in_collection: false) ⇒ Presenter
constructor
A new instance of Presenter.
Constructor Details
#initialize(presented, in_collection: false) ⇒ Presenter
Returns a new instance of Presenter.
22 23 24 25 |
# File 'lib/bumbleworks/api/lib/presenter.rb', line 22 def initialize(presented, in_collection: false) @presented = presented @in_collection = in_collection end |
Instance Attribute Details
#presented ⇒ Object (readonly)
Returns the value of attribute presented.
4 5 6 |
# File 'lib/bumbleworks/api/lib/presenter.rb', line 4 def presented @presented end |
Class Method Details
.from_array(array) ⇒ Object
15 16 17 18 19 |
# File 'lib/bumbleworks/api/lib/presenter.rb', line 15 def from_array(array) array.map { |presented| new(presented, in_collection: true) } end |
.present(presented) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/bumbleworks/api/lib/presenter.rb', line 7 def present(presented) if presented.is_a?(Array) from_array(presented) else new(presented) end end |
Instance Method Details
#in_collection? ⇒ Boolean
27 28 29 |
# File 'lib/bumbleworks/api/lib/presenter.rb', line 27 def in_collection? @in_collection == true end |