Module: Cuprum::Collections::Relation::Parameters
- Included in:
- Collection, Cuprum::Collections::Relation
- Defined in:
- lib/cuprum/collections/relation.rb
Overview
Methods for resolving a relations’s naming and entity class from options.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the relation.
-
#plural_name ⇒ String
readonly
The pluralized name of the relation.
-
#qualified_name ⇒ String
readonly
A scoped name for the relation.
-
#singular_name ⇒ String
readonly
The name of an entity in the relation.
Class Method Summary collapse
-
.resolve_parameters(entity_class: nil, singular_name: nil, name: nil, qualified_name: nil) ⇒ Hash
Helper method for resolving a Relation’s required parameters.
Instance Method Summary collapse
-
#entity_class ⇒ Class
The class of entity represented by the relation.
-
#resolve_parameters(entity_class: nil, singular_name: nil, name: nil, qualified_name: nil) ⇒ Hash
Helper method for resolving a Relation’s required parameters.
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of the relation.
311 312 313 |
# File 'lib/cuprum/collections/relation.rb', line 311 def name @name end |
#plural_name ⇒ String (readonly)
Returns the pluralized name of the relation.
314 315 316 |
# File 'lib/cuprum/collections/relation.rb', line 314 def plural_name @plural_name end |
#qualified_name ⇒ String (readonly)
Returns a scoped name for the relation.
317 318 319 |
# File 'lib/cuprum/collections/relation.rb', line 317 def qualified_name @qualified_name end |
#singular_name ⇒ String (readonly)
Returns the name of an entity in the relation.
320 321 322 |
# File 'lib/cuprum/collections/relation.rb', line 320 def singular_name @singular_name end |
Class Method Details
.resolve_parameters(entity_class: nil, singular_name: nil, name: nil, qualified_name: nil) ⇒ Hash
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/cuprum/collections/relation.rb', line 164 def resolve_parameters(params) # rubocop:disable Metrics/MethodLength validate_parameters(**params) entity_class = entity_class_from(**params) class_name = entity_class_name(entity_class) name = relation_name_from(**params, class_name: class_name) plural_name = plural_name_from(**params, name: name) qualified_name = qualified_name_from(**params, class_name: class_name) singular_name = singular_name_from(**params, name: name) { entity_class: entity_class, name: name, plural_name: plural_name, qualified_name: qualified_name, singular_name: singular_name } end |
Instance Method Details
#entity_class ⇒ Class
Returns the class of entity represented by the relation.
323 324 325 326 327 |
# File 'lib/cuprum/collections/relation.rb', line 323 def entity_class return @entity_class if @entity_class.is_a?(Class) @entity_class = Object.const_get(@entity_class) end |
#resolve_parameters(entity_class: nil, singular_name: nil, name: nil, qualified_name: nil) ⇒ Hash
330 331 332 |
# File 'lib/cuprum/collections/relation.rb', line 330 def resolve_parameters(parameters) Parameters.resolve_parameters(parameters) end |