Sha256: d896826654f73b3a5e61e031efe3b5a3b629c580861aa015bd733a540284b1ee

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 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 created_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("#{TicketMaster::Provider::Github.login}/#{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("#{TicketMaster::Provider::Github.login}/#{project_id}", ticket_id, comment)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ticketmaster-github-0.4.1 lib/provider/comment.rb