Class: Cuprum::Collections::Commands::Associations::FindMany

Inherits:
Cuprum::Command
  • Object
show all
Defined in:
lib/cuprum/collections/commands/associations/find_many.rb

Overview

Command for querying entities by association.

Direct Known Subclasses

RequireMany

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(association:, repository:, resource:) ⇒ FindMany

Returns a new instance of FindMany.

Parameters:



56
57
58
59
60
61
62
# File 'lib/cuprum/collections/commands/associations/find_many.rb', line 56

def initialize(association:, repository:, resource:)
  super()

  @association = association
  @repository  = repository
  @resource    = resource
end

Instance Attribute Details

#associationCuprum::Collections::Association (readonly)

Returns the association to query.

Returns:



65
66
67
# File 'lib/cuprum/collections/commands/associations/find_many.rb', line 65

def association
  @association
end

#repositoryCuprum::Collections::Repository (readonly)

Returns the repository to query from.

Returns:



68
69
70
# File 'lib/cuprum/collections/commands/associations/find_many.rb', line 68

def repository
  @repository
end

#resourceCuprum::Collections::Resource (readonly)

Returns the base resource for the association.

Returns:



72
73
74
# File 'lib/cuprum/collections/commands/associations/find_many.rb', line 72

def resource
  @resource
end

Instance Method Details

#call(key: ) ⇒ Object, ... #call(keys: ) ⇒ Array<Object> #call(entity: ) ⇒ Object, ... #call(entities: ) ⇒ Array<Object>

Overloads:

  • #call(key: ) ⇒ Object, ...

    Finds the association values for the given key.

    Parameters:

    • key (Object) (defaults to: )

      the primary or foreign key for querying the association.

    Returns:

    • (Object, nil)

      the association value or nil, if the association is singular.

    • (Array<Object>)

      the association values, if the association is plural.

  • #call(keys: ) ⇒ Array<Object>

    Finds the association values for the given Array of keys.

    Parameters:

    • keys (Array<Object>) (defaults to: )

      the primary or foreign keys for querying the association.

    Returns:

    • (Array<Object>)

      the association values.

    • (Array<Object>)

      the association values.

  • #call(entity: ) ⇒ Object, ...

    Finds the association values for the given entity.

    Parameters:

    • entity (Object) (defaults to: )

      the base entity for querying the association.

    Returns:

    • (Object, nil)

      the association value or nil, if the association is singular.

    • (Array<Object>)

      the association values, if the association is plural.

  • #call(entities: ) ⇒ Array<Object>

    Finds the association values for the given Array of entities.

    Parameters:

    • entity (Array<Object>)

      the base entities for querying the association.

    Returns:

    • (Array<Object>)

      the association values.



# File 'lib/cuprum/collections/commands/associations/find_many.rb', line 11