Module: OData::Model::Configuration::ClassMethods
- Defined in:
- lib/odata/model/configuration.rb
Overview
Methods mixed in at the class level.
Instance Method Summary collapse
-
#for_entity(entity_name) ⇒ nil
Define the entity set to use for the current OData::Model.
-
#limit_default_selection ⇒ nil
Sets the configuration option to cause a select operation to be set by default that only queries for the properties defined in the model.
-
#odata_config ⇒ Hash
private
Returns the configuration for working with the OData gem.
-
#odata_entity_set ⇒ OData::EntitySet
private
Returns the OData::EntitySet the current model is related to.
-
#odata_entity_set_name ⇒ String
private
Returns the entity set name this model is related to.
-
#odata_namespace ⇒ String
private
Get the OData::Service’s namespace.
-
#odata_service ⇒ OData::Service
private
Get the OData::Service.
-
#odata_service_name ⇒ String
private
Returns the name of the OData::Service used.
-
#use_entity_set(set_name) ⇒ nil
Define the entity set to use for the current OData::Model.
-
#use_service(service_key) ⇒ nil
Define the service to use for the current OData::Model.
Instance Method Details
#for_entity(entity_name) ⇒ nil
Define the entity set to use for the current OData::Model. This method will look up the correct EntitySet using the Entity’s type name.
68 69 70 71 |
# File 'lib/odata/model/configuration.rb', line 68 def for_entity(entity_name) odata_config[:entity_set_name] = odata_service.entity_sets[entity_name] nil end |
#limit_default_selection ⇒ nil
Sets the configuration option to cause a select operation to be set by default that only queries for the properties defined in the model.
77 78 79 80 |
# File 'lib/odata/model/configuration.rb', line 77 def limit_default_selection odata_config[:limit_default_selection] = true nil end |
#odata_config ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the configuration for working with the OData gem.
106 107 108 109 110 111 112 113 |
# File 'lib/odata/model/configuration.rb', line 106 def odata_config if class_variable_defined?(:@@odata_config) class_variable_get(:@@odata_config) else class_variable_set(:@@odata_config, {}) class_variable_get(:@@odata_config) end end |
#odata_entity_set ⇒ OData::EntitySet
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the OData::EntitySet the current model is related to.
125 126 127 |
# File 'lib/odata/model/configuration.rb', line 125 def odata_entity_set odata_config[:entity_set] ||= odata_service[odata_entity_set_name] end |
#odata_entity_set_name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the entity set name this model is related to.
118 119 120 |
# File 'lib/odata/model/configuration.rb', line 118 def odata_entity_set_name odata_config[:entity_set_name] ||= self.name.pluralize end |
#odata_namespace ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the OData::Service’s namespace
99 100 101 |
# File 'lib/odata/model/configuration.rb', line 99 def odata_namespace odata_service.try(:namespace) end |
#odata_service ⇒ OData::Service
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the OData::Service
85 86 87 |
# File 'lib/odata/model/configuration.rb', line 85 def odata_service odata_config[:service] end |
#odata_service_name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the name of the OData::Service used.
92 93 94 |
# File 'lib/odata/model/configuration.rb', line 92 def odata_service_name odata_config[:service].name end |
#use_entity_set(set_name) ⇒ nil
Define the entity set to use for the current OData::Model. This method will record in the OData configuration the supplied name so that it can be used to communicate properly with the underlying OData::Service.
57 58 59 60 |
# File 'lib/odata/model/configuration.rb', line 57 def use_entity_set(set_name) odata_config[:entity_set_name] = set_name.to_s nil end |
#use_service(service_key) ⇒ nil
Define the service to use for the current OData::Model. This method will cause the service to be looked up in the OData::ServiceRegistry by the supplied key, so it can accept either the service’s URL or its namespace.
45 46 47 48 |
# File 'lib/odata/model/configuration.rb', line 45 def use_service(service_key) odata_config[:service] = OData::ServiceRegistry[service_key.to_s] nil end |