Class: Playbook::Props::Enum

Inherits:
Base
  • Object
show all
Defined in:
lib/playbook/props/enum.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#default, #deprecated, #kit, #name, #required

Instance Method Summary collapse

Methods inherited from Base

#validate!, #value

Constructor Details

#initialize(values:, **options) ⇒ Enum

Returns a new instance of Enum.



8
9
10
11
# File 'lib/playbook/props/enum.rb', line 8

def initialize(values:, **options)
  super(**options)
  @values = values
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



6
7
8
# File 'lib/playbook/props/enum.rb', line 6

def values
  @values
end

Instance Method Details

#validate(value) ⇒ Object



13
14
15
# File 'lib/playbook/props/enum.rb', line 13

def validate(value)
  @values.include?(value)
end