lib/compel/builder/schema.rb in compel-0.3.6 vs lib/compel/builder/schema.rb in compel-0.3.7
- old
+ new
@@ -8,22 +8,36 @@
attr_reader :type,
:options
def initialize(type)
@type = type
- @options = Hashie::Mash.new
+ @options = default_options
end
def required?
- !!options[:required]
+ options[:required]
end
def default_value
options[:default]
end
def validate(object)
Contract.new(object, self).validate
+ end
+
+ class << self
+
+ def human_name
+ "#{self.name.split('::')[1..-1].join('::')}"
+ end
+
+ end
+
+ protected
+
+ def default_options
+ Hashie::Mash.new(required: false)
end
end
end