Sha256: 64eaa94597b048b7e6e7ce55df7f1c20b2034d50c55476802e991c092c13523f
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 KB
Contents
require 'active_resource' module RedmineRest module Models # # Model of issue relations # class Relation < ActiveResource::Base TYPES = %w(relates duplicates duplicated blocks blocked precedes follows copied_to copied_from).freeze self.format = :xml self.prefix = '/issues/:issue_id/' validate :validate_relation_type, :validate_issue_id, :validate_issue_to_id # # Overrides parent method. # When we want to fetch one relation, we need not to use prefix # def self.element_path(id, _prefix_options = {}, query_options = nil) "/relations/#{URI.parser.escape id.to_s}#{format_extension}#{query_string(query_options)}" end private def validate_relation_type errors.add(:relation_type, 'Wrong relation type') unless relation_type? && TYPES.include?(relation_type) end def validate_issue_id errors.add(:issue_id, 'Issue ID required') unless issue_id? end def validate_issue_to_id errors.add(:issue_to_id, 'Issue ID required') unless issue_to_id? end end end end
Version data entries
4 entries across 4 versions & 1 rubygems