lib/neo4j/shared/enum.rb in neo4j-8.0.0.alpha.2 vs lib/neo4j/shared/enum.rb in neo4j-8.0.0.alpha.4

- old
+ new

@@ -62,12 +62,11 @@ else fail ArgumentError, 'Invalid parameter for enum. Please provide an Array or an Hash.' end end - VALID_OPTIONS_FOR_ENUMS = [:_prefix, :_suffix] - DEFAULT_OPTIONS_FOR_ENUMS = {} + VALID_OPTIONS_FOR_ENUMS = [:_index, :_prefix, :_suffix, :_default] def split_options_and_parameters(parameters) options = {} new_parameters = {} parameters.each do |k, v| @@ -78,12 +77,19 @@ end end [options, new_parameters] end - def define_property(property_name, enum_keys, _options) - property property_name, default: enum_keys.keys.first # .merge(options) - serialize property_name, Neo4j::Shared::TypeConverters::EnumConverter.new(enum_keys) + def define_property(property_name, enum_keys, options) + property_options = build_property_options(enum_keys, options) + property property_name, property_options + serialize property_name, Neo4j::Shared::TypeConverters::EnumConverter.new(enum_keys, property_options) + end + + def build_property_options(_enum_keys, options = {}) + { + default: options[:_default] + } end def define_enum_methods(property_name, enum_keys, options) define_enum_methods_?(property_name, enum_keys, options) define_enum_methods_!(property_name, enum_keys, options)