Class: Troo::Card
- Inherits:
-
Ohm::Model
- Object
- Ohm::Model
- Troo::Card
- Includes:
- Ohm::DataTypes, ModelHelpers
- Defined in:
- lib/troo/models/card.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#board ⇒ Object
[].
-
#comment_presenter(options = {}) ⇒ Object
[].
- #comments ⇒ Ohm::Set
-
#decorator(options = {}) ⇒ Object
[].
- #external_member_ids ⇒ Array, String
-
#list ⇒ Object
[].
- #members ⇒ Array
- #presenter(options = {}) ⇒ Troo::Presenters::Card
-
#recent_comments ⇒ Object
[].
- #type ⇒ Symbol
Methods included from ModelHelpers
Class Method Details
.remote ⇒ Remote::Card
30 31 32 |
# File 'lib/troo/models/card.rb', line 30 def remote Remote::Card end |
.type ⇒ Symbol
35 36 37 |
# File 'lib/troo/models/card.rb', line 35 def type :card end |
Instance Method Details
#board ⇒ Object
Returns [].
52 53 54 |
# File 'lib/troo/models/card.rb', line 52 def board @board ||= Troo::Board.retrieve(external_board_id) end |
#comment_presenter(options = {}) ⇒ Object
Returns [].
93 94 95 |
# File 'lib/troo/models/card.rb', line 93 def comment_presenter( = {}) Presenters::Comment.new(self, ) end |
#comments ⇒ Ohm::Set
62 63 64 |
# File 'lib/troo/models/card.rb', line 62 def comments Troo::Comment.find(external_card_id: external_id) end |
#decorator(options = {}) ⇒ Object
Returns [].
81 82 83 |
# File 'lib/troo/models/card.rb', line 81 def decorator( = {}) Decorators::Resource.new(self, ) end |
#external_member_ids ⇒ Array, String
41 42 43 44 45 46 47 48 49 |
# File 'lib/troo/models/card.rb', line 41 def external_member_ids if @attributes[:external_member_ids].nil? [] elsif @attributes[:external_member_ids].is_a?(Array) @attributes[:external_member_ids] else JSON(@attributes[:external_member_ids]) end end |
#list ⇒ Object
Returns [].
57 58 59 |
# File 'lib/troo/models/card.rb', line 57 def list @list ||= Troo::List.retrieve(external_list_id) end |
#members ⇒ Array
72 73 74 75 76 77 |
# File 'lib/troo/models/card.rb', line 72 def members return [] if external_member_ids.empty? @members ||= external_member_ids.map do |member_id| Troo::Member.retrieve(member_id) end.compact end |
#presenter(options = {}) ⇒ Troo::Presenters::Card
87 88 89 |
# File 'lib/troo/models/card.rb', line 87 def presenter( = {}) Presenters::Card.new(self, ) end |
#recent_comments ⇒ Object
Returns [].
67 68 69 |
# File 'lib/troo/models/card.rb', line 67 def recent_comments comments.sort(by: :date, limit: [0, 3]) end |
#type ⇒ Symbol
98 99 100 |
# File 'lib/troo/models/card.rb', line 98 def type self.class.type end |