Class: Jabara::MySQL::Schema::Boolean

Inherits:
Object
  • Object
show all
Defined in:
lib/jabara/mysql/schema.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.tagObject



51
52
53
# File 'lib/jabara/mysql/schema.rb', line 51

def self.tag
  :boolean
end

Instance Method Details

#parse(data) ⇒ Object

Raises:

  • (ArgumentError)


55
56
57
58
59
60
# File 'lib/jabara/mysql/schema.rb', line 55

def parse(data)
  raise ArgumentError, 'must be string' unless data.is_a? ::String
  return true if data == 'true'
  return false if data == 'false'
  raise ArgumentError, 'must be "true" or "false"'
end

#validate(repr) ⇒ Object



62
63
64
65
66
# File 'lib/jabara/mysql/schema.rb', line 62

def validate(repr)
  data = ::Jabara.data(repr)
  return true if [true, false].include? data
  return false, 'must be "true" or "false"'
end