Class: Super::Filter::FormObject::OperatorForm
- Inherits:
-
Object
- Object
- Super::Filter::FormObject::OperatorForm
- Defined in:
- lib/super/filter/form_object.rb
Constant Summary collapse
- NULLARY =
:_apply
Instance Attribute Summary collapse
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#specified_values ⇒ Object
readonly
Returns the value of attribute specified_values.
Instance Method Summary collapse
- #each_field ⇒ Object
- #identifier ⇒ Object
-
#initialize(operator:, params:) ⇒ OperatorForm
constructor
A new instance of OperatorForm.
- #specified? ⇒ Boolean
Constructor Details
#initialize(operator:, params:) ⇒ OperatorForm
Returns a new instance of OperatorForm.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/super/filter/form_object.rb', line 40 def initialize(operator:, params:) @operator = operator @params = params || {} query_parameter_keys = operator.query_parameter_keys query_parameter_keys = [NULLARY] if query_parameter_keys.empty? @specified_values = query_parameter_keys .map { |key| [key, @params[key].presence&.strip] } .to_h @specified_values.each do |key, value| define_singleton_method(key) { value } end end |
Instance Attribute Details
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
59 60 61 |
# File 'lib/super/filter/form_object.rb', line 59 def operator @operator end |
#specified_values ⇒ Object (readonly)
Returns the value of attribute specified_values.
60 61 62 |
# File 'lib/super/filter/form_object.rb', line 60 def specified_values @specified_values end |
Instance Method Details
#each_field ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/super/filter/form_object.rb', line 66 def each_field return enum_for(:each_field) if !block_given? @specified_values.each do |key, _value| yield(key) end end |
#identifier ⇒ Object
62 63 64 |
# File 'lib/super/filter/form_object.rb', line 62 def identifier @operator.identifier end |
#specified? ⇒ Boolean
55 56 57 |
# File 'lib/super/filter/form_object.rb', line 55 def specified? @specified_values.any? { |_key, value| value } end |