Sha256: 363ef4f9220ad9007d5ce5e74f39c64a9ca03292aa1ea23970cbfcc4a9e09f72

Contents?: true

Size: 486 Bytes

Versions: 1

Compression:

Stored size: 486 Bytes

Contents

require 'hashie/dash'

module Polytrix
  class Validation < Hashie::Dash
    ALLOWABLE_STATES = %w(passed pending failed skipped)
    property :validated_by, required: true
    property :result

    def result=(state)
      fail invalidate_state_error unless ALLOWABLE_STATES.include? state
      super
    end

    protected

    def invalidate_state_error(state)
      ArgumentError.new "Invalid result state: #{state}, should be one of #{ALLOWABLE_STATES.inspect}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polytrix-0.1.0.pre lib/polytrix/validation.rb