module Paradocs::DSL

Public Class Methods

included(base) click to toggle source

Example

class Foo
  include Paradocs::DSL

  schema do
    field(:title).type(:string).present
    field(:age).type(:integer).default(20)
  end

   attr_reader :params

   def initialize(input)
     @params = self.class.schema.resolve(input)
   end
end

foo = Foo.new(title: "A title", nope: "hello")

foo.params # => {title: "A title", age: 20}
# File lib/paradocs/dsl.rb, line 26
def self.included(base)
  base.extend(ClassMethods)
  base.schemas = {Paradocs.config.default_schema_name => Paradocs::Schema.new}
end