Module: SexyJSONSchemas::DSL

Defined in:
lib/sexy_json_schemas/dsl.rb

Instance Method Summary collapse

Instance Method Details

#as_jsonObject



14
15
16
17
18
# File 'lib/sexy_json_schemas/dsl.rb', line 14

def as_json
  definition = SchemaDefinition.new(@schema_name, @schema_options)
  definition.instance_eval(&@definition_block)
  definition.as_json
end

#schema(name, options = {}, &block) ⇒ Object



3
4
5
6
7
8
# File 'lib/sexy_json_schemas/dsl.rb', line 3

def schema(name, options = {}, &block)
  options[:root_element] ||= name unless options[:root_element] == false
  @schema_name      = name
  @schema_options   = options
  @definition_block = block
end

#schema_nameObject



10
11
12
# File 'lib/sexy_json_schemas/dsl.rb', line 10

def schema_name
  @schema_name
end