Class: Hamachi::EnumField

Inherits:
Field
  • Object
show all
Defined in:
lib/hamachi/source/field.rb

Instance Method Summary collapse

Methods inherited from Field

#default_value, #initialize_options

Constructor Details

#initialize(*symbols) ⇒ EnumField

Returns a new instance of EnumField.



38
39
40
# File 'lib/hamachi/source/field.rb', line 38

def initialize(*symbols)
  super symbols
end

Instance Method Details

#===(value) ⇒ Object



42
43
44
# File 'lib/hamachi/source/field.rb', line 42

def ===(value)
  @type.any? { |each| each === value }
end

#from_snapshot(data, options) ⇒ Object



50
51
52
# File 'lib/hamachi/source/field.rb', line 50

def from_snapshot(data, options)
  String === data ? data.to_sym : data
end

#to_sObject



46
47
48
# File 'lib/hamachi/source/field.rb', line 46

def to_s
  "enum(#{@type.map(&:inspect).join(?,)})"
end