Class: ActiveInteraction::ObjectFilter
- Defined in:
- lib/active_interaction/filters/object_filter.rb
Overview
Instance Attribute Summary
Attributes inherited from Filter
Instance Method Summary collapse
-
#cast(value, context, reconstantize: true, convert: true) ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods inherited from Filter
#clean, #database_column_type, #default, #default?, #desc, factory, #initialize
Constructor Details
This class inherits a constructor from ActiveInteraction::Filter
Instance Method Details
#cast(value, context, reconstantize: true, convert: true) ⇒ Object
rubocop:disable Metrics/MethodLength
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/active_interaction/filters/object_filter.rb', line 33 def cast(value, context, reconstantize: true, convert: true) @klass ||= klass if matches?(value) value elsif reconstantize @klass = klass public_send(__method__, value, context, reconstantize: false, convert: convert ) elsif !value.nil? && convert && (converter = [:converter]) value = convert(klass, value, converter) public_send(__method__, value, context, reconstantize: reconstantize, convert: false ) else super(value, context) end end |