Class: Schash::Schema::DSL
- Inherits:
-
Object
- Object
- Schash::Schema::DSL
- Defined in:
- lib/schash/schema/dsl.rb
Class Method Summary collapse
Instance Method Summary collapse
- #array ⇒ Object
- #array_of(schema) ⇒ Object
- #boolean ⇒ Object
- #float ⇒ Object
- #integer ⇒ Object
- #match(pattern) ⇒ Object
- #numeric ⇒ Object
- #one_of_types(*schemas) ⇒ Object
- #optional(rule) ⇒ Object
- #string ⇒ Object
- #symbol ⇒ Object
- #type(klass) ⇒ Object
Class Method Details
.evaluate(&block) ⇒ Object
4 5 6 |
# File 'lib/schash/schema/dsl.rb', line 4 def self.evaluate(&block) self.new.instance_eval(&block) end |
Instance Method Details
#array ⇒ Object
44 45 46 |
# File 'lib/schash/schema/dsl.rb', line 44 def array type(Array) end |
#array_of(schema) ⇒ Object
8 9 10 |
# File 'lib/schash/schema/dsl.rb', line 8 def array_of(schema) Rule::ArrayOf.new(schema) end |
#boolean ⇒ Object
48 49 50 |
# File 'lib/schash/schema/dsl.rb', line 48 def boolean one_of_types(TrueClass, FalseClass) end |
#float ⇒ Object
36 37 38 |
# File 'lib/schash/schema/dsl.rb', line 36 def float type(Float) end |
#integer ⇒ Object
32 33 34 |
# File 'lib/schash/schema/dsl.rb', line 32 def integer type(Integer) end |
#match(pattern) ⇒ Object
52 53 54 |
# File 'lib/schash/schema/dsl.rb', line 52 def match(pattern) Rule::Match.new(pattern) end |
#numeric ⇒ Object
28 29 30 |
# File 'lib/schash/schema/dsl.rb', line 28 def numeric type(Numeric) end |
#one_of_types(*schemas) ⇒ Object
12 13 14 |
# File 'lib/schash/schema/dsl.rb', line 12 def one_of_types(*schemas) Rule::OneOfTypes.new(*schemas) end |
#optional(rule) ⇒ Object
20 21 22 |
# File 'lib/schash/schema/dsl.rb', line 20 def optional(rule) Rule::Optional.new(rule) end |
#string ⇒ Object
24 25 26 |
# File 'lib/schash/schema/dsl.rb', line 24 def string type(String) end |
#symbol ⇒ Object
40 41 42 |
# File 'lib/schash/schema/dsl.rb', line 40 def symbol type(Symbol) end |