Class: ParamsReady::Query::VariableOperatorPredicateDefinition
- Inherits:
-
AbstractPredicateDefinition
- Object
- Parameter::AbstractDefinition
- AbstractPredicateDefinition
- ParamsReady::Query::VariableOperatorPredicateDefinition
- Includes:
- HavingAttribute
- Defined in:
- lib/params_ready/query/variable_operator_predicate.rb
Instance Attribute Summary collapse
-
#struct_parameter ⇒ Object
readonly
Returns the value of attribute struct_parameter.
-
#struct_parameter_builder ⇒ Object
readonly
Returns the value of attribute struct_parameter_builder.
Attributes inherited from Parameter::AbstractDefinition
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(*args, attribute_name: nil, **opts) ⇒ VariableOperatorPredicateDefinition
constructor
A new instance of VariableOperatorPredicateDefinition.
- #set_operators(array, &block) ⇒ Object
- #set_type(type) ⇒ Object
Methods inherited from Parameter::AbstractDefinition
#create, #from_hash, #from_input, #normalize_alternative_name, #parameter_class
Methods included from Extensions::Freezer
#freeze_variable, #freeze_variables, #variables_to_freeze
Methods included from Extensions::Finalizer
Methods included from Extensions::ClassReaderWriter
Methods included from Extensions::LateInit
Methods included from Extensions::Collection
Methods included from Extensions::Freezer::InstanceMethods
Constructor Details
#initialize(*args, attribute_name: nil, **opts) ⇒ VariableOperatorPredicateDefinition
Returns a new instance of VariableOperatorPredicateDefinition.
88 89 90 91 92 93 |
# File 'lib/params_ready/query/variable_operator_predicate.rb', line 88 def initialize(*args, attribute_name: nil, **opts) super *args, **opts @attribute_name = attribute_name @struct_parameter_builder = Builder.builder(:struct).instance(name, altn: altn) @operator_parameter_builder = Builder.builder(:predicate_operator).instance(:operator, altn: :op) end |
Instance Attribute Details
#struct_parameter ⇒ Object (readonly)
Returns the value of attribute struct_parameter.
86 87 88 |
# File 'lib/params_ready/query/variable_operator_predicate.rb', line 86 def struct_parameter @struct_parameter end |
#struct_parameter_builder ⇒ Object (readonly)
Returns the value of attribute struct_parameter_builder.
85 86 87 |
# File 'lib/params_ready/query/variable_operator_predicate.rb', line 85 def struct_parameter_builder @struct_parameter_builder end |
Instance Method Details
#finish ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/params_ready/query/variable_operator_predicate.rb', line 113 def finish @struct_parameter = @struct_parameter_builder.build @struct_parameter_builder = nil @operator_parameter_builder = nil @type = nil super end |
#set_operators(array, &block) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/params_ready/query/variable_operator_predicate.rb', line 100 def set_operators(array, &block) context = Format.instance(:backend) operators = array.map do |name| PredicateRegistry.operator(name, context) end @operator_parameter_builder.include do constrain :enum, operators end @operator_parameter_builder.include(&block) unless block.nil? @struct_parameter_builder.add @operator_parameter_builder.build end |
#set_type(type) ⇒ Object
95 96 97 98 |
# File 'lib/params_ready/query/variable_operator_predicate.rb', line 95 def set_type(type) @type = type @struct_parameter_builder.add @type.finish end |