Sha256: 7df432d83c9094e91785036c76128f87d2ebfc36cdb4fd2d45026e08a65db6d8

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'stratify-github/presenter'
require 'stratify-github/translation'

module Stratify
  module GitHub
    class Activity < Stratify::Activity
      extend Stratify::GitHub::Translation

      field :checksum
      field :url
      field :actor
      field :repository
      field :action   # 'created', 'deleted', etc.
      field :ref      # The human/ref name for a branch, tag, etc.
      field :ref_type # 'branch', 'repo', 'tag'...
      field :thing    # The acted-upon item. ('target' is reserved by mongoid.)
      field :payload  # A text snippet of the comment, gists, etc.
      field :event_type

      natural_key :checksum

      validates_presence_of :checksum, :url, :actor, :event_type

      def permalink
        url
      end

      # Let the values of this object's fields inform its checksum.
      def to_str
        fields.collect do |field, body|
          send(field) if body.type == Object
        end.compact.sort.join(' ')
      end
      
      def to_html
        Stratify::GitHub::Presenter.new(self).to_html
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stratify-github-0.1 lib/stratify-github/activity.rb