Class: FullMetalBody::DynamicWhitelistGenerator

Inherits:
Object
  • Object
show all
Includes:
InputKeyUtils
Defined in:
lib/full_metal_body/dynamic_whitelist_generator.rb

Defined Under Namespace

Classes: ParseArrayError

Instance Method Summary collapse

Constructor Details

#initialize(keys, value, whitelist = {}) ⇒ DynamicWhitelistGenerator

Returns a new instance of DynamicWhitelistGenerator.

Parameters:

  • keys (Array<String,Symbol>)
  • value (Object)
  • whitelist (Hash) (defaults to: {})


11
12
13
14
15
# File 'lib/full_metal_body/dynamic_whitelist_generator.rb', line 11

def initialize(keys, value, whitelist = {})
  @keys = keys
  @value = value
  @whitelist = whitelist
end

Instance Method Details

#execute!ActiveSupport::HashWithIndifferentAccess

Dynamically generate a whitelist and return a merged one.

Returns:

  • (ActiveSupport::HashWithIndifferentAccess)


19
20
21
22
23
24
25
26
27
28
# File 'lib/full_metal_body/dynamic_whitelist_generator.rb', line 19

def execute!
  if keys_isnt_whitelisted?
    if keys_include_array?(@keys)
      generate_whitelist_for_array(@keys)
    else
      @whitelist.bury!((@keys + ['type']), type_definition_by_value)
    end
  end
  @whitelist.with_indifferent_access
end