Class: ParamsReady::Query::RelationDefinition
- Inherits:
-
StructuredGroupingDefinition
- Object
- Parameter::AbstractDefinition
- Parameter::Definition
- Parameter::AbstractStructParameterDefinition
- Parameter::StructParameterDefinition
- StructuredGroupingDefinition
- ParamsReady::Query::RelationDefinition
- Defined in:
- lib/params_ready/query/relation.rb
Instance Attribute Summary collapse
-
#joins ⇒ Object
readonly
Returns the value of attribute joins.
Attributes inherited from StructuredGroupingDefinition
Attributes inherited from Parameter::AbstractStructParameterDefinition
Attributes inherited from Parameter::Definition
Attributes inherited from Parameter::AbstractDefinition
Instance Method Summary collapse
- #arel_table ⇒ Object
- #finish ⇒ Object
- #init_ordering_builder(empty:) ⇒ Object
-
#initialize(*args, **opts) ⇒ RelationDefinition
constructor
A new instance of RelationDefinition.
- #model_class ⇒ Object
- #model_class_defined? ⇒ Boolean
Methods inherited from StructuredGroupingDefinition
Methods inherited from Parameter::StructParameterDefinition
#add_map, #ensure_canonical, #remap?
Methods inherited from Parameter::AbstractStructParameterDefinition
#add_child, #child_definition, #duplicate_value, #freeze_value, #has_child?, #infer_default, #set_default
Methods inherited from Parameter::Definition
#canonical_default, #default_defined?, #fetch_callable_default, #fetch_default, #memoize?, #name_for_formatter, #no_input?, #no_output?, #postprocess, #preprocess, #restricted_for_format?, #set_local, #set_no_input, #set_postprocessor, #set_preprocessor
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, **opts) ⇒ RelationDefinition
Returns a new instance of RelationDefinition.
337 338 339 340 341 |
# File 'lib/params_ready/query/relation.rb', line 337 def initialize(*args, **opts) @joins = [] @ordering_builder = nil super end |
Instance Attribute Details
#joins ⇒ Object (readonly)
Returns the value of attribute joins.
335 336 337 |
# File 'lib/params_ready/query/relation.rb', line 335 def joins @joins end |
Instance Method Details
#arel_table ⇒ Object
327 328 329 |
# File 'lib/params_ready/query/relation.rb', line 327 def arel_table model_class.arel_table end |
#finish ⇒ Object
343 344 345 346 347 |
# File 'lib/params_ready/query/relation.rb', line 343 def finish raise ParamsReadyError, 'Ordering must be explicitly declared' if @ordering_builder&.open? @ordering_builder = nil super end |
#init_ordering_builder(empty:) ⇒ Object
322 323 324 325 |
# File 'lib/params_ready/query/relation.rb', line 322 def init_ordering_builder(empty:) raise ParamsReadyError, 'Ordering already defined' if empty == true && !@ordering_builder.nil? @ordering_builder ||= Ordering::OrderingParameterBuilder.instance end |
#model_class ⇒ Object
317 318 319 320 |
# File 'lib/params_ready/query/relation.rb', line 317 def model_class raise ParamsReadyError, "Model class not set for #{name}" if @model_class.nil? @model_class end |
#model_class_defined? ⇒ Boolean
331 332 333 |
# File 'lib/params_ready/query/relation.rb', line 331 def model_class_defined? !@model_class.nil? end |