Class: Cuprum::Rails::Actions::Middleware::Associations::Query

Inherits:
Cuprum::Rails::Action show all
Includes:
Middleware
Defined in:
lib/cuprum/rails/actions/middleware/associations/query.rb

Overview

Abstract middleware for performing an association query.

Direct Known Subclasses

Find, Parent

Instance Attribute Summary collapse

Attributes inherited from Cuprum::Rails::Action

#options

Instance Method Summary collapse

Methods inherited from Cuprum::Rails::Action

#call, #params

Constructor Details

#initialize(association_type: nil, **association_params) ⇒ Query

Returns a new instance of Query.

Parameters:

  • association_type (String, Symbol) (defaults to: nil)

    the type of association.

  • association_params (Hash)

    parameters to pass to the association.



17
18
19
20
21
22
# File 'lib/cuprum/rails/actions/middleware/associations/query.rb', line 17

def initialize(association_type: nil, **association_params)
  super()

  @association_type = association_type&.intern
  @association      = build_association(**association_params)
end

Instance Attribute Details

#associationCuprum::Collections::Association (readonly)

Returns the association.

Returns:

  • (Cuprum::Collections::Association)

    the association.



25
26
27
# File 'lib/cuprum/rails/actions/middleware/associations/query.rb', line 25

def association
  @association
end

#association_typeString, Symbol (readonly)

Returns the type of association.

Returns:

  • (String, Symbol)

    the type of association.



28
29
30
# File 'lib/cuprum/rails/actions/middleware/associations/query.rb', line 28

def association_type
  @association_type
end