Module: Apify::SchemaHelper
- Defined in:
- lib/apify/schema_helper.rb
Instance Method Summary collapse
- #array(items = nil) ⇒ Object
- #boolean ⇒ Object
- #email ⇒ Object
- #enum(schema, allowed_values) ⇒ Object
- #integer ⇒ Object
- #number ⇒ Object
- #object(properties = nil) ⇒ Object
- #optional(schema) ⇒ Object
- #sql_date ⇒ Object
- #sql_datetime ⇒ Object
- #string ⇒ Object
- #url ⇒ Object
Instance Method Details
#array(items = nil) ⇒ Object
14 15 16 17 18 |
# File 'lib/apify/schema_helper.rb', line 14 def array(items = nil) { 'type' => 'array' }.tap do |schema| schema['items'] = items if items end end |
#boolean ⇒ Object
24 25 26 |
# File 'lib/apify/schema_helper.rb', line 24 def boolean { 'type' => 'boolean' } end |
#email ⇒ Object
50 51 52 53 |
# File 'lib/apify/schema_helper.rb', line 50 def email { 'type' => 'string', 'pattern' => Apify::Patterns::EMAIL.source } end |
#enum(schema, allowed_values) ⇒ Object
28 29 30 |
# File 'lib/apify/schema_helper.rb', line 28 def enum(schema, allowed_values) schema.merge('enum' => allowed_values) end |
#integer ⇒ Object
36 37 38 |
# File 'lib/apify/schema_helper.rb', line 36 def integer { 'type' => 'integer' } end |
#number ⇒ Object
32 33 34 |
# File 'lib/apify/schema_helper.rb', line 32 def number { 'type' => 'number' } end |
#object(properties = nil) ⇒ Object
8 9 10 11 12 |
# File 'lib/apify/schema_helper.rb', line 8 def object(properties = nil) { 'type' => 'object' }.tap do |schema| schema['properties'] = properties if properties end end |
#optional(schema) ⇒ Object
4 5 6 |
# File 'lib/apify/schema_helper.rb', line 4 def optional(schema) schema.merge('optional' => true) end |
#sql_date ⇒ Object
40 41 42 43 |
# File 'lib/apify/schema_helper.rb', line 40 def sql_date { 'type' => 'string', 'pattern' => Apify::Patterns::SQL_DATE.source } end |
#sql_datetime ⇒ Object
45 46 47 48 |
# File 'lib/apify/schema_helper.rb', line 45 def sql_datetime { 'type' => 'string', 'pattern' => Apify::Patterns::SQL_DATETIME.source } end |
#string ⇒ Object
20 21 22 |
# File 'lib/apify/schema_helper.rb', line 20 def string { 'type' => 'string' } end |