Class: Troo::Card

Inherits:
Ohm::Model
  • Object
show all
Includes:
Ohm::DataTypes, ModelHelpers
Defined in:
lib/troo/models/card.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ModelHelpers

included

Class Method Details

.remoteRemote::Card

Returns:



30
31
32
# File 'lib/troo/models/card.rb', line 30

def remote
  Remote::Card
end

.typeSymbol

Returns:

  • (Symbol)


35
36
37
# File 'lib/troo/models/card.rb', line 35

def type
  :card
end

Instance Method Details

#boardObject

Returns [].

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 [].

Parameters:

  • (Hash)

Returns:



93
94
95
# File 'lib/troo/models/card.rb', line 93

def comment_presenter(options = {})
  Presenters::Comment.new(self, options)
end

#commentsOhm::Set

Returns:

  • (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 [].

Parameters:

  • (Hash)

Returns:



81
82
83
# File 'lib/troo/models/card.rb', line 81

def decorator(options = {})
  Decorators::Resource.new(self, options)
end

#external_member_idsArray, String

Returns:

  • (Array, 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

#listObject

Returns [].

Returns:



57
58
59
# File 'lib/troo/models/card.rb', line 57

def list
  @list ||= Troo::List.retrieve(external_list_id)
end

#membersArray

Returns:

  • (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

Parameters:

  • (Hash)

Returns:



87
88
89
# File 'lib/troo/models/card.rb', line 87

def presenter(options = {})
  Presenters::Card.new(self, options)
end

#recent_commentsObject

Returns [].

Returns:



67
68
69
# File 'lib/troo/models/card.rb', line 67

def recent_comments
  comments.sort(by: :date, limit: [0, 3])
end

#typeSymbol

Returns:

  • (Symbol)


98
99
100
# File 'lib/troo/models/card.rb', line 98

def type
  self.class.type
end