Class: Cuprum::Collections::Relation

Inherits:
Object
  • Object
show all
Includes:
Parameters
Defined in:
lib/cuprum/collections/relation.rb

Overview

Abstract class representing a group or view of entities.

Direct Known Subclasses

Resource

Defined Under Namespace

Modules: Cardinality, Disambiguation, Parameters, PrimaryKeys

Instance Attribute Summary collapse

Attributes included from Parameters

#name, #plural_name, #qualified_name, #singular_name

Instance Method Summary collapse

Methods included from Parameters

#entity_class, resolve_parameters, #resolve_parameters

Constructor Details

#initialize(entity_class: nil, name: nil, qualified_name: nil, singular_name: nil, **options) ⇒ Relation

Returns a new instance of Relation.

Parameters:

  • entity_class (Class, String) (defaults to: nil)

    the class of entity represented by the relation.

  • name (String) (defaults to: nil)

    the name of the relation.

  • qualified_name (String) (defaults to: nil)

    a scoped name for the relation.

  • singular_name (String) (defaults to: nil)

    the name of an entity in the relation.

  • options (Hash)

    additional options for the relation.



370
371
372
373
374
375
376
377
378
379
380
# File 'lib/cuprum/collections/relation.rb', line 370

def initialize(**parameters)
  relation_params = resolve_parameters(parameters)

  @entity_class   = relation_params[:entity_class]
  @name           = relation_params[:name]
  @plural_name    = relation_params[:plural_name]
  @qualified_name = relation_params[:qualified_name]
  @singular_name  = relation_params[:singular_name]

  @options = ignore_parameters(**parameters)
end

Instance Attribute Details

#optionsHash (readonly)

Returns additional options for the relation.

Returns:

  • (Hash)

    additional options for the relation.



383
384
385
# File 'lib/cuprum/collections/relation.rb', line 383

def options
  @options
end