Class: ParamsReady::Query::RelationDefinition

Instance Attribute Summary collapse

Attributes inherited from StructuredGroupingDefinition

#predicates

Attributes inherited from Parameter::AbstractStructParameterDefinition

#key_map, #names

Attributes inherited from Parameter::Definition

#default

Attributes inherited from Parameter::AbstractDefinition

#altn, #name

Instance Method Summary collapse

Methods inherited from StructuredGroupingDefinition

#add_predicate

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

#obligatory, #obligatory!

Methods included from Extensions::ClassReaderWriter

#class_reader_writer

Methods included from Extensions::LateInit

#late_init

Methods included from Extensions::Collection

#collection

Methods included from Extensions::Freezer::InstanceMethods

#freeze

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

#joinsObject (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_tableObject



327
328
329
# File 'lib/params_ready/query/relation.rb', line 327

def arel_table
  model_class.arel_table
end

#finishObject

Raises:



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

Raises:



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_classObject

Raises:



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

Returns:

  • (Boolean)


331
332
333
# File 'lib/params_ready/query/relation.rb', line 331

def model_class_defined?
  !@model_class.nil?
end