Sha256: 8378d811cacd88918d83f85188e6ef590ec4872980ea632afdc177727269f53d

Contents?: true

Size: 1.34 KB

Versions: 10

Compression:

Stored size: 1.34 KB

Contents

module TicketMaster::Provider
  module Github
    # The comment class for ticketmaster-github
    #
    # Do any mapping between Ticketmaster and your system's comment model here
    # versions of the ticket.
    #
    class Comment < TicketMaster::Provider::Base::Comment
      attr_accessor :prefix_options
      
      def initialize(*options)
        if options.first.is_a? Hash
          object = options.first
          @system_data = {:client => object}
          object[:author] = object['user']
          object[:project_id] = options[1]
          object[:ticket_id] = options[2]
          super object
        end
      end

      def created_at
        @created_at ||= begin
          Time.parse(self[:created_at])
          rescue
          self[:created_at]
          end
      end

       def updated_at
        @updated_at ||= begin
          Time.parse(self[:updated_at])
          rescue
          self[:updated_at]
          end
      end
      
      # declare needed overloaded methods here
       
      def self.find(project_id, ticket_id)
        TicketMaster::Provider::Github.api.issue_comments(project_id, ticket_id).collect { |comment| self.new comment }
      end

      def self.create(project_id, ticket_id, comment)
        self.new TicketMaster::Provider::Github.api.add_comment(project_id, ticket_id, comment)
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ticketmaster-github-0.6.5 lib/provider/comment.rb
ticketmaster-github-0.6.4 lib/provider/comment.rb
ticketmaster-github-0.6.3 lib/provider/comment.rb
ticketmaster-github-0.5.3 lib/provider/comment.rb
ticketmaster-github-0.5.2 lib/provider/comment.rb
ticketmaster-github-0.5.1 lib/provider/comment.rb
ticketmaster-github-0.5.0 lib/provider/comment.rb
ticketmaster-github-0.4.9 lib/provider/comment.rb
ticketmaster-github-0.4.8 lib/provider/comment.rb
ticketmaster-github-0.4.7 lib/provider/comment.rb