module Paradocs::DSL::ClassMethods

Public Instance Methods

inherited(subclass) click to toggle source
# File lib/paradocs/dsl.rb, line 40
def inherited(subclass)
  subclass.schemas = @schemas.each_with_object({}) do |(key, sc), hash|
    hash[key] = sc.merge(Paradocs::Schema.new)
  end
end
paradocs_after_define_schema(sc) click to toggle source
# File lib/paradocs/dsl.rb, line 63
def paradocs_after_define_schema(sc)
  # noop hook
end
schema(*args, &block) click to toggle source
# File lib/paradocs/dsl.rb, line 46
def schema(*args, &block)
  options = args.last.is_a?(Hash) ? args.last : {}
  key = args.first.is_a?(Symbol) ? args.shift : Paradocs.config.default_schema_name
  current_schema = @schemas.fetch(key) { Paradocs::Schema.new }
  new_schema = if block_given? || options.any?
    Paradocs::Schema.new(options, &block)
  elsif args.first.is_a?(Paradocs::Schema)
    args.first
  end

  return current_schema unless new_schema

  @schemas[key] = current_schema ? current_schema.merge(new_schema) : new_schema
  paradocs_after_define_schema(@schemas[key])
  @schemas[key]
end
schema=(sc) click to toggle source
# File lib/paradocs/dsl.rb, line 32
def schema=(sc)
  @schemas[Paradocs.config.default_schema_name] = sc
end
schemas=(sc) click to toggle source
# File lib/paradocs/dsl.rb, line 36
def schemas=(sc)
  @schemas = sc
end