lib/attributor.rb in attributor-7.1 vs lib/attributor.rb in attributor-8.0

- old
+ new

@@ -1,7 +1,6 @@ require 'json' -require 'randexp' require 'hashie' require 'active_support/concern' require 'digest/sha1' @@ -15,12 +14,10 @@ require_relative 'attributor/hash_dsl_compiler' require_relative 'attributor/smart_attribute_selector' require_relative 'attributor/example_mixin' - require_relative 'attributor/extensions/randexp' - # hierarchical separator string for composing human readable attributes SEPARATOR = '.'.freeze ROOT_PREFIX = '$'.freeze DEFAULT_ROOT_CONTEXT = [ROOT_PREFIX].freeze @@ -35,15 +32,17 @@ klass end def self.find_type(attr_type) return attr_type if attr_type < Attributor::Type + name = attr_type.name.split('::').last # TOO EXPENSIVE? klass = const_get(name) if const_defined?(name) raise AttributorException, "Could not find class with name #{name}" unless klass raise AttributorException, "Could not find attribute type for: #{name} [klass: #{klass.name}]" unless klass < Attributor::Type + klass end def self.type_name(type) return type_name(type.class) unless type.is_a?(::Class) @@ -55,11 +54,11 @@ return '' unless context context = Array(context) if context.is_a? ::String begin - return context.join('.') + context.join('.') rescue e raise "Error creating context string: #{e.message}" end end @@ -79,10 +78,10 @@ hash[name] = recursive_to_h(inner_val) end else val end - end + end MODULE_PREFIX = 'Attributor::'.freeze MODULE_PREFIX_REGEX = ::Regexp.new(MODULE_PREFIX) require_relative 'attributor/families/numeric'