Class: Cuprum::Collections::Resource
- Includes:
- Cuprum::Collections::Relation::Cardinality, Cuprum::Collections::Relation::Disambiguation, Cuprum::Collections::Relation::PrimaryKeys
- Defined in:
- lib/cuprum/collections/resource.rb
Overview
Class representing a singular or plural resource of entities.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Relation
Attributes included from Cuprum::Collections::Relation::Parameters
#name, #plural_name, #qualified_name, #singular_name
Instance Method Summary collapse
-
#initialize(entity_class: nil, name: nil, qualified_name: nil, singular_name: nil, **options) ⇒ Resource
constructor
A new instance of Resource.
-
#resource_class ⇒ Class
The class of entity represented by the resource.
-
#resource_name ⇒ String
The name of the resource.
-
#singular_resource_name ⇒ Object
@return the name of an entity in the resource.
Methods included from Cuprum::Collections::Relation::PrimaryKeys
#primary_key_name, #primary_key_type
Methods included from Cuprum::Collections::Relation::Disambiguation
disambiguate_keyword, #disambiguate_keyword, resolve_parameters, #resolve_parameters
Methods included from Cuprum::Collections::Relation::Cardinality
Methods included from Cuprum::Collections::Relation::Parameters
#entity_class, resolve_parameters, #resolve_parameters
Constructor Details
#initialize(entity_class: nil, name: nil, qualified_name: nil, singular_name: nil, **options) ⇒ Resource
Returns a new instance of Resource.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cuprum/collections/resource.rb', line 28 def initialize(**params) params = disambiguate_keyword(params, :entity_class, :resource_class) params = disambiguate_keyword(params, :name, :resource_name) params = disambiguate_keyword( params, :singular_name, :singular_resource_name ) @plural = resolve_plurality(**params) super(**params) end |
Instance Method Details
#resource_class ⇒ Class
Returns the class of entity represented by the resource.
42 43 44 45 46 47 |
# File 'lib/cuprum/collections/resource.rb', line 42 def resource_class tools.core_tools.deprecate '#resource_class method', message: 'Use #entity_class instead' entity_class end |
#resource_name ⇒ String
Returns the name of the resource.
50 51 52 53 54 55 |
# File 'lib/cuprum/collections/resource.rb', line 50 def resource_name tools.core_tools.deprecate '#resource_name method', message: 'Use #name instead' name end |
#singular_resource_name ⇒ Object
@return the name of an entity in the resource.
58 59 60 61 62 63 |
# File 'lib/cuprum/collections/resource.rb', line 58 def singular_resource_name tools.core_tools.deprecate '#singular_resource_name method', message: 'Use #singular_name instead' singular_name end |