Class: OData::PropertyRegistry

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/odata/property_registry.rb

Overview

Provides a registry for keeping track of various property types used by OData.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](type_name) ⇒ Class?

Lookup a property by name and get the Ruby class to use for its instances

Parameters:

  • type_name (String)

    the type name to lookup

Returns:

  • (Class, nil)

    the proper class or nil



31
32
33
# File 'lib/odata/property_registry.rb', line 31

def self.[](type_name)
  OData::PropertyRegistry.instance[type_name]
end

.add(type_name, klass) ⇒ Object

Add a property type to the registry

Parameters:

  • type_name (String)

    property type name to register

  • klass (Class)

    Ruby class to use for the specified type



26
27
28
# File 'lib/odata/property_registry.rb', line 26

def self.add(type_name, klass)
  OData::PropertyRegistry.instance.add(type_name, klass)
end

Instance Method Details

#[](type_name) ⇒ Class?

Lookup a property by name and get the Ruby class to use for its instances

Parameters:

  • type_name (String)

    the type name to lookup

Returns:

  • (Class, nil)

    the proper class or nil



21
22
23
# File 'lib/odata/property_registry.rb', line 21

def [](type_name)
  properties[type_name]
end

#add(type_name, klass) ⇒ Object

Add a property type to the registry

Parameters:

  • type_name (String)

    property type name to register

  • klass (Class)

    Ruby class to use for the specified type



13
14
15
# File 'lib/odata/property_registry.rb', line 13

def add(type_name, klass)
  properties[type_name] = klass
end