module OData::Model::Configuration::ClassMethods

Methods mixed in at the class level.

Public Instance Methods

for_entity(entity_name) click to toggle source

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
limit_default_selection() click to toggle source

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
odata_config() click to toggle source

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
odata_entity_set() click to toggle source

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
odata_entity_set_name() click to toggle source

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
odata_namespace() click to toggle source

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
odata_service() click to toggle source

Get the OData::Service @return [OData::Service] @api private

# File lib/odata/model/configuration.rb, line 85
def odata_service
  odata_config[:service]
end
odata_service_name() click to toggle source

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
use_entity_set(set_name) click to toggle source

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
use_service(service_key) click to toggle source

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