module JSON::SchemaBuilder::DSL
Public Instance Methods
entity(*args, &block)
click to toggle source
# File lib/json/schema_builder/dsl.rb, line 7 def entity(*args, &block) opts = args.extract_options! klass, name = klass_and_name_from args set_context_for opts klass.new(name, opts, &block).tap do reinitialize if is_a?(Entity) end end
Protected Instance Methods
klass_and_name_from(args)
click to toggle source
# File lib/json/schema_builder/dsl.rb, line 26 def klass_and_name_from(args) type, name = args if DSL.types[type] [DSL.types[type], name] else [Entity, type] end end
set_context_for(opts)
click to toggle source
# File lib/json/schema_builder/dsl.rb, line 18 def set_context_for(opts) if is_a?(Entity) opts[:parent] ||= self else opts[:root] = self end end