module OData::Model::Configuration::ClassMethods
Methods mixed in at the class level.
Public Instance Methods
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.
@param entity_name [to_s] name of EntityType used by OData
Service @return [nil]
# 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
Sets the configuration option to cause a select operation to be set by default that only queries for the properties defined in the model.
@return [nil]
# File lib/odata/model/configuration.rb, line 77 def limit_default_selection odata_config[:limit_default_selection] = true nil end
Returns the configuration for working with the OData
gem. @return [Hash] @api private
# 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
Returns the OData::EntitySet the current model is related to. @return [OData::EntitySet] @api private
# File lib/odata/model/configuration.rb, line 125 def odata_entity_set odata_config[:entity_set] ||= odata_service[odata_entity_set_name] end
Returns the entity set name this model is related to. @return [String] @api private
# File lib/odata/model/configuration.rb, line 118 def odata_entity_set_name odata_config[:entity_set_name] ||= self.name.pluralize end
Get the OData::Service’s namespace @return [String] OData
Service’s namespace @api private
# File lib/odata/model/configuration.rb, line 99 def odata_namespace odata_service.try(:namespace) end
Get the OData::Service @return [OData::Service] @api private
# File lib/odata/model/configuration.rb, line 85 def odata_service odata_config[:service] end
Returns the name of the OData::Service used. @return [String] @api private
# File lib/odata/model/configuration.rb, line 92 def odata_service_name odata_config[:service].name end
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.
@param set_name [to_s] name of EntitySet used by OData
service @return [nil]
# 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
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.
@param service_key [to_s] service URL or namespace @return [nil]
# File lib/odata/model/configuration.rb, line 45 def use_service(service_key) odata_config[:service] = OData::ServiceRegistry[service_key.to_s] nil end