Sha256: 262bd92526e370ef6f64d8779cd7f1ce7f43a92a712af2e4fadfcb681a9c527f

Contents?: true

Size: 356 Bytes

Versions: 69

Compression:

Stored size: 356 Bytes

Contents

# frozen_string_literal: true

module ReeEnum::Contractable
  include Ree::Contracts::Truncatable

  def valid?(value)
    value.is_a?(ReeEnum::Value) && value.enum_name == self.enum_name && all.include?(value)
  end

  def message(value, name, lvl = 1)
    return "expected one of #{self.name}, got #{value.class} => #{truncate(value.inspect)}"
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
ree_lib-1.0.69 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.68 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.67 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.66 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.65 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.64 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.63 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.62 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.61 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.60 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.59 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.58 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.57 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.56 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.55 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.54 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.53 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.52 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.51 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb
ree_lib-1.0.50 lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb