Class: JSONSkooma::Keywords::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/json_skooma/keywords/base.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent_schema, value) ⇒ Base

Returns a new instance of Base.



38
39
40
41
# File 'lib/json_skooma/keywords/base.rb', line 38

def initialize(parent_schema, value)
  @parent_schema = parent_schema
  @json = wrap_value(value)
end

Class Attribute Details

.depends_onObject

Returns the value of attribute depends_on.



9
10
11
# File 'lib/json_skooma/keywords/base.rb', line 9

def depends_on
  @depends_on
end

.instance_typesObject

Returns the value of attribute instance_types.



11
12
13
# File 'lib/json_skooma/keywords/base.rb', line 11

def instance_types
  @instance_types
end

.keyObject



13
14
15
# File 'lib/json_skooma/keywords/base.rb', line 13

def key
  @key or raise "Key must be defined"
end

.schema_value_classObject

Returns the value of attribute schema_value_class.



9
10
11
# File 'lib/json_skooma/keywords/base.rb', line 9

def schema_value_class
  @schema_value_class
end

.staticObject

Returns the value of attribute static.



9
10
11
# File 'lib/json_skooma/keywords/base.rb', line 9

def static
  @static
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



6
7
8
# File 'lib/json_skooma/keywords/base.rb', line 6

def json
  @json
end

#parent_schemaObject (readonly)

Returns the value of attribute parent_schema.



6
7
8
# File 'lib/json_skooma/keywords/base.rb', line 6

def parent_schema
  @parent_schema
end

Class Method Details

.inherited(subclass) ⇒ Object



33
34
35
# File 'lib/json_skooma/keywords/base.rb', line 33

def inherited(subclass)
  subclass.set_defaults
end

.set_defaultsObject



27
28
29
30
31
# File 'lib/json_skooma/keywords/base.rb', line 27

def set_defaults
  @instance_types = %w[boolean object array string number null]
  @static = false
  @depends_on = []
end

.value_schema=(schema_keys) ⇒ Object



21
22
23
24
25
# File 'lib/json_skooma/keywords/base.rb', line 21

def value_schema=(schema_keys)
  Array(schema_keys).each do |k|
    prepend ValueSchemas[k]
  end
end

Instance Method Details

#each_schema(&block) ⇒ Object



58
59
# File 'lib/json_skooma/keywords/base.rb', line 58

def each_schema(&block)
end

#evaluate(instance, result) ⇒ Object



55
56
# File 'lib/json_skooma/keywords/base.rb', line 55

def evaluate(instance, result)
end

#instance_typesObject



51
52
53
# File 'lib/json_skooma/keywords/base.rb', line 51

def instance_types
  self.class.instance_types
end

#keyObject



43
44
45
# File 'lib/json_skooma/keywords/base.rb', line 43

def key
  self.class.key
end

#resolveObject



61
62
63
64
65
# File 'lib/json_skooma/keywords/base.rb', line 61

def resolve
  each_schema do |schema|
    schema.resolve_references if schema.respond_to?(:resolve_references)
  end
end

#staticObject



47
48
49
# File 'lib/json_skooma/keywords/base.rb', line 47

def static
  self.class.static
end