Sha256: 096c6456dcc5ad5c2660f76be5df0c59d00aa57eb8b3e144fb8dec9619e9a6f1

Contents?: true

Size: 1.56 KB

Versions: 4

Compression:

Stored size: 1.56 KB

Contents

module Troo
  module Remote
    class Comment
      include Virtus.model(finalize: false)
      include Troo::RemoteModelHelpers

      attribute :id
      attribute :idMemberCreator
      attribute :data,            Troo::Remote::CommentData
      attribute :type
      attribute :date
      attribute :memberCreator,   Troo::Remote::Member

      class << self
        # @return [Hash]
        def remote_options
          { mode: :card }
        end

        # @return [Hash]
        def by_board_id
          {
            endpoint: :comments_by_board_id,
            query:    { filter: :commentCard }
          }
        end

        # @return [Hash]
        def by_card_id
          {
            endpoint: :comments_by_card_id,
            query:    { filter: :commentCard }
          }
        end
      end

      # @return []
      def external_board_id
        data.board.id
      end

      # @return []
      def external_card_id
        data.card.id
      end

      # @return []
      def external_comment_id
        id
      end

      # @return []
      def text
        data.text
      end

      # @return [Array]
      def associations
        [:memberCreator]
      end

      # @return []
      def local_model
        Troo::Comment
      end

      # @return [Hash]
      def adapted
        {
          external_id:        id,
          external_board_id:  data.board.id,
          external_card_id:   data.card.id,
          external_member_id: idMemberCreator,
          date:               date,
          text:               text
        }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
troo-0.0.14 lib/troo/remote/comment.rb
troo-0.0.13 lib/troo/remote/comment.rb
troo-0.0.12 lib/troo/remote/comment.rb
troo-0.0.11 lib/troo/remote/comment.rb