Module: ReeEnum::Contractable

Includes:
Ree::Contracts::Truncatable
Included in:
Enumerable::ClassMethods
Defined in:
lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb

Instance Method Summary collapse

Instance Method Details

#message(value, name, lvl = 1) ⇒ Object



10
11
12
# File 'lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb', line 10

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

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/ree_lib/packages/ree_enum/package/ree_enum/contractable.rb', line 6

def valid?(value)
  value.is_a?(ReeEnum::Value) && value.enum_name == get_enum_name && get_values.each.include?(value)
end