Sha256: f608b1b4ed890889c33d524e40bd1532b93fd7b1b834586e267a4334fc4d4910
Contents?: true
Size: 1.52 KB
Versions: 5
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true module Jimmy module Declaration # Acceptable values for +#type+. SIMPLE_TYPES = Set.new(%w[array boolean integer null number object string]).freeze # Set the type(s) of the schema. # @param [String, Array<String>] types The type(s) of the schema. # @return [self] self, for chaining def type(*types) types = types.flatten types.each &method(:assert_simple_type) assert_array types, unique: true, minimum: 1 types = Array(get('type') { [] }) | types.flatten types = types.first if types.one? set type: types end alias types type SIMPLE_TYPES.each do |type| class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{type} type '#{type}' end RUBY end alias nullable null # Generated by `rake yard`. Do not modify anything below here. # # @!method array() # Make the schema allow type "array". # @return [Schema] # @!method boolean() # Make the schema allow type "boolean". # @return [Schema] # @!method integer() # Make the schema allow type "integer". # @return [Schema] # @!method null() # Make the schema allow type "null". # @return [Schema] # @!method number() # Make the schema allow type "number". # @return [Schema] # @!method object() # Make the schema allow type "object". # @return [Schema] # @!method string() # Make the schema allow type "string". # @return [Schema] end end
Version data entries
5 entries across 5 versions & 1 rubygems