Sha256: 29660e13c343a593c4821398c5159e21181154db741fbf0c74345c8a156c8eab

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

require 'active_model'

module RedmineRest
  module Models
    class Issue < ActiveResource::Base
      class Journal
        #
        # Journal detail
        #
        class Detail
          include ActiveModel::Model
          attr_accessor :property, :name, :old_value, :new_value

          def attribute?
            property == 'attr'
          end

          def relation?
            property == 'relation'
          end

          def method_missing(m, *args)
            m = m.to_s

            return super unless args.empty? && m.to_s.end_with?('?')
            name == m.to_s[0..-2]
          end

          def to_s
            if attribute?
              "#{name}: #{old_value.nil? ? 'nil' : old_value} -> #{new_value.nil? ? 'nil' : new_value}"
            elsif relation?
              "#{name} #{new_value}"
            else
              super
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redmine_rest-0.8.0 lib/redmine_rest/models/issue/journal_detail.rb