Class: Datacaster::ContextNodes::StructureCleaner
- Inherits:
-
Datacaster::ContextNode
- Object
- Base
- Datacaster::ContextNode
- Datacaster::ContextNodes::StructureCleaner
- Defined in:
- lib/datacaster/context_nodes/structure_cleaner.rb
Instance Method Summary collapse
-
#initialize(base, strategy = :fail) ⇒ StructureCleaner
constructor
A new instance of StructureCleaner.
- #inspect ⇒ Object
Methods inherited from Datacaster::ContextNode
Methods included from Mixin
#&, #*, #call, #call_with_runtime, #cast_errors, #i18n_key, #i18n_map_keys, #i18n_scope, #i18n_vars, #then, #with_context, #with_object_context, #with_runtime, #|
Constructor Details
#initialize(base, strategy = :fail) ⇒ StructureCleaner
Returns a new instance of StructureCleaner.
4 5 6 7 8 9 10 11 12 |
# File 'lib/datacaster/context_nodes/structure_cleaner.rb', line 4 def initialize(base, strategy = :fail) super(base) unless %i[fail remove pass].include?(strategy) raise ArgumentError.new("Strategy should be :fail (return error on extra keys), :remove (remove extra keys) or :pass (ignore presence of extra keys), instead got #{strategy.inspect}") end @strategy = strategy end |
Instance Method Details
#inspect ⇒ Object
14 15 16 |
# File 'lib/datacaster/context_nodes/structure_cleaner.rb', line 14 def inspect "#<#{self.class.name}(#{@strategy}) base: #{@base.inspect}>" end |