class Neo4j::Shared::TypeConverters::EnumConverter

Public Class Methods

new(enum_keys, options) click to toggle source
    # File lib/neo4j/shared/type_converters.rb
274 def initialize(enum_keys, options)
275   @enum_keys = enum_keys
276   @options = options
277 
278   return unless @options[:case_sensitive].nil?
279 
280   @options[:case_sensitive] = Neo4j::Config.enums_case_sensitive
281 end

Public Instance Methods

call(value)
Alias for: to_ruby
convert_type() click to toggle source
    # File lib/neo4j/shared/type_converters.rb
295 def convert_type
296   Symbol
297 end
converted?(value) click to toggle source
    # File lib/neo4j/shared/type_converters.rb
283 def converted?(value)
284   value.is_a?(db_type)
285 end
db_type() click to toggle source
    # File lib/neo4j/shared/type_converters.rb
291 def db_type
292   Integer
293 end
supports_array?() click to toggle source
    # File lib/neo4j/shared/type_converters.rb
287 def supports_array?
288   true
289 end
to_db(value) click to toggle source
    # File lib/neo4j/shared/type_converters.rb
305 def to_db(value)
306   if value.is_a?(Array)
307     value.map(&method(:to_db))
308   elsif @options[:case_sensitive]
309     @enum_keys[value.to_s.to_sym] ||
310       fail(Neo4j::Shared::Enum::InvalidEnumValueError, 'Value passed to an enum property must match one of the enum keys')
311   else
312     @enum_keys[value.to_s.downcase.to_sym] ||
313       fail(Neo4j::Shared::Enum::InvalidEnumValueError, 'Case-insensitive (downcased) value passed to an enum property must match one of the enum keys')
314   end
315 end
to_ruby(value) click to toggle source
    # File lib/neo4j/shared/type_converters.rb
299 def to_ruby(value)
300   @enum_keys.key(value) unless value.nil?
301 end
Also aliased as: call