Sha256: 3b019b9132adf81bf6b68f0e882a41816ce884e161edf8e5a35082c77f0c53ef
Contents?: true
Size: 448 Bytes
Versions: 14
Compression:
Stored size: 448 Bytes
Contents
module HaveAPI::Client class Parameters::Resource attr_reader :errors def initialize(params, desc, value) @errors = [] @value = coerce(value) end def valid? @errors.empty? end def to_api @value end protected def coerce(v) if !v.is_a?(::Integer) && /\A\d+\z/ !~ v @errors << 'not a valid resource id' nil else v.to_i end end end end
Version data entries
14 entries across 14 versions & 1 rubygems