lib/troo/models/card.rb in troo-0.0.8 vs lib/troo/models/card.rb in troo-0.0.9

- old
+ new

@@ -12,22 +12,29 @@ attribute :last_activity_date attribute :default, Type::Boolean attribute :closed, Type::Boolean attribute :external_board_id attribute :external_list_id - attribute :external_card_id + attribute :external_id index :short_id index :default index :external_board_id index :external_list_id - index :external_card_id + index :external_id - alias_method :default?, :default + alias_method :default?, :default + alias_method :description, :desc - def self.remote(id, options = { mode: :card }) - External::Card.fetch(id, options).first + class << self + def remote + Remote::Card + end + + def type + :card + end end def external_member_ids if @attributes[:external_member_ids].nil? [] @@ -37,48 +44,44 @@ JSON(@attributes[:external_member_ids]) end end def board - @board ||= Retrieval::Board.retrieve(external_board_id) + @board ||= Troo::Board.retrieve(external_board_id) end def list - @list ||= Retrieval::List.retrieve(external_list_id) + @list ||= Troo::List.retrieve(external_list_id) end def comments - Troo::Comment.find(external_card_id: external_card_id) + Troo::Comment.find(external_card_id: external_id) end def recent_comments comments.sort(by: :date, limit: [0, 3]) end def members return [] if external_member_ids.empty? @members ||= external_member_ids.map do |member_id| - Retrieval::Member.retrieve(member_id) + Troo::Member.retrieve(member_id) end.compact end def decorator(options = {}) - Decorators::Card.new(self, options) + Decorators::Resource.new(self, options) end def presenter(options = {}) - Presenters::Card.new(self, options) + Presenters::Card.new(decorator, options) end def comment_presenter(options = {}) Presenters::Comment.new(self, options) end - def member_presenter(options = {}) - Presenters::Member.new(self, options) - end - - def set_default! - Behaviours::SetDefault.for(self) + def type + self.class.type end end end