Method: JSI::Base::HashNode#jsi_each_propertyName

Defined in:
lib/jsi/base/node.rb

#jsi_each_propertyName {|JSI::Base| ... } ⇒ nil, Enumerator

instantiates and yields each property name (hash key) as a JSI described by any propertyNames schemas.

Yields:

Returns:

  • (nil, Enumerator)

    an Enumerator if invoked without a block; otherwise nil



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jsi/base/node.rb', line 11

def jsi_each_propertyName
  return to_enum(__method__) { jsi_node_content_hash_pubsend(:size) } unless block_given?

  property_schemas = SchemaSet.build do |schemas|
    jsi_schemas.each do |s|
      if s.keyword?('propertyNames') && s['propertyNames'].is_a?(Schema)
        schemas << s['propertyNames']
      end
    end
  end
  jsi_node_content_hash_pubsend(:each_key) do |key|
    yield property_schemas.new_jsi(key)
  end

  nil
end