Module: StructuraidCore::DesignCodes::Utils::CodeRequirement::ClassMethods

Defined in:
lib/structuraid_core/design_codes/utils/code_requirement.rb

Instance Method Summary collapse

Instance Method Details

#call(params = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/structuraid_core/design_codes/utils/code_requirement.rb', line 18

def call(params = {})
  schema_klass.validate!(params)
  sanitized_params = schema_klass.structurize(params)
  sanitized_params.members.each do |param_name|
    define_method(param_name) { sanitized_params[param_name] }
  end

  obj = new(sanitized_params)
  obj.call
end

#schema_klassObject



29
30
31
# File 'lib/structuraid_core/design_codes/utils/code_requirement.rb', line 29

def schema_klass
  @schema_klass
end