Module: PivotalTracker::Validation
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pivotal-tracker/validation.rb', line 32 def self.included(klass) klass.class_eval do if klass.instance_methods.include?(:create) alias_method :create_without_validations, :create alias_method :create, :create_with_validations end if klass.instance_methods.include?(:update) alias_method :update_without_validations, :update alias_method :update, :update_with_validations end end end |
Instance Method Details
#create_with_validations ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/pivotal-tracker/validation.rb', line 46 def create_with_validations begin create_without_validations rescue RestClient::UnprocessableEntity => e errors.add_from_xml e.response self end end |
#errors ⇒ Object
64 65 66 |
# File 'lib/pivotal-tracker/validation.rb', line 64 def errors @errors ||= Errors.new end |
#update_with_validations(attrs = {}) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/pivotal-tracker/validation.rb', line 55 def update_with_validations(attrs={}) begin update_without_validations attrs rescue RestClient::UnprocessableEntity => e errors.add_from_xml e.response self end end |