Skip to content

Commit

Permalink
Load error from unknown module name (#11)
Browse files Browse the repository at this point in the history
* load error

* version bump
  • Loading branch information
matt-taylor authored Apr 2, 2022
1 parent 0033c0e commit 2b46e0f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
2 changes: 2 additions & 0 deletions lib/json_schematize.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "json_schematize/version"

require "json_schematize/base"
require "json_schematize/boolean"
require "json_schematize/generator"
Expand Down
8 changes: 5 additions & 3 deletions lib/json_schematize/base.rb
Original file line number Diff line number Diff line change
@@ -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
22 changes: 12 additions & 10 deletions lib/json_schematize/boolean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/json_schematize/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module JsonSchematize
VERSION = "0.6.0"
VERSION = "0.6.1"
end

0 comments on commit 2b46e0f

Please sign in to comment.