Module: Lurker::Json::Parser::Expertise

Included in:
PlainStrategy, TypedStrategy
Defined in:
lib/lurker/json/parser/expertise.rb

Class Method Summary collapse

Class Method Details

.type_defined?(hash) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/lurker/json/parser/expertise.rb', line 13

def type_defined?(hash)
  return false unless hash.is_a?(Hash)

  hash.key?(Json::TYPE) && Json::PRIMITIVES.include?(hash[Json::TYPE])
end

.type_polymorph?(array_or_hash) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
# File 'lib/lurker/json/parser/expertise.rb', line 7

def type_polymorph?(array_or_hash)
  return false unless array_or_hash.is_a?(Hash) || array_or_hash.is_a?(Array)

  array_or_hash.empty?
end

.type_supposed?(hash) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
# File 'lib/lurker/json/parser/expertise.rb', line 19

def type_supposed?(hash)
  return false unless hash.is_a?(Hash)

  hash.key?(Json::ANYOF) || hash.key?(Json::ALLOF) || hash.key?(Json::ONEOF) ||
  hash.key?(Json::ITEMS) || hash.key?(Json::PROPERTIES) ||
  hash.key?(Json::REF)
end