From 2b46e0f9c95924e0a5f57aff261b5e12d34894ff Mon Sep 17 00:00:00 2001 From: Matt Taylor <3680737+matt-taylor@users.noreply.github.com> Date: Fri, 1 Apr 2022 23:36:52 -0700 Subject: [PATCH] Load error from unknown module name (#11) * load error * version bump --- lib/json_schematize.rb | 2 ++ lib/json_schematize/base.rb | 8 +++++--- lib/json_schematize/boolean.rb | 22 ++++++++++++---------- lib/json_schematize/version.rb | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/json_schematize.rb b/lib/json_schematize.rb index 41528f8..52dd382 100644 --- a/lib/json_schematize.rb +++ b/lib/json_schematize.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "json_schematize/version" + require "json_schematize/base" require "json_schematize/boolean" require "json_schematize/generator" diff --git a/lib/json_schematize/base.rb b/lib/json_schematize/base.rb index 2b5d916..d1f84b7 100644 --- a/lib/json_schematize/base.rb +++ b/lib/json_schematize/base.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true -class JsonSchematize::Base - def self.acceptable_types - raise NoMethodError, "Expected acceptable_values to be defined in parent class" +module JsonSchematize + class Base + def self.acceptable_types + raise NoMethodError, "Expected acceptable_values to be defined in parent class" + end end end diff --git a/lib/json_schematize/boolean.rb b/lib/json_schematize/boolean.rb index 05c113d..21085b3 100644 --- a/lib/json_schematize/boolean.rb +++ b/lib/json_schematize/boolean.rb @@ -2,18 +2,20 @@ require "json_schematize/base" -class JsonSchematize::Boolean < JsonSchematize::Base - FALSE_VALUES = ["false", "f", "0", false] - TRUE_VALUES = ["true", "t", "1", true] +module JsonSchematize + class Boolean < JsonSchematize::Base + FALSE_VALUES = ["false", "f", "0", false] + TRUE_VALUES = ["true", "t", "1", true] - def self.new(val) - return false if FALSE_VALUES.include?(val) - return true if TRUE_VALUES.include?(val) + def self.new(val) + return false if FALSE_VALUES.include?(val) + return true if TRUE_VALUES.include?(val) - raise JsonSchematize::UndefinedBoolean, "#{val} is not a valid #{self.class}" - end + raise JsonSchematize::UndefinedBoolean, "#{val} is not a valid #{self.class}" + end - def self.acceptable_types - [TrueClass, FalseClass] + def self.acceptable_types + [TrueClass, FalseClass] + end end end diff --git a/lib/json_schematize/version.rb b/lib/json_schematize/version.rb index a62a94c..4eaab71 100644 --- a/lib/json_schematize/version.rb +++ b/lib/json_schematize/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module JsonSchematize - VERSION = "0.6.0" + VERSION = "0.6.1" end