Class: ActiveRemote::Type::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/active_remote/type/registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.



6
7
8
# File 'lib/active_remote/type/registry.rb', line 6

def initialize
  @registrations = []
end

Instance Attribute Details

#registrationsObject (readonly)

Returns the value of attribute registrations.



4
5
6
# File 'lib/active_remote/type/registry.rb', line 4

def registrations
  @registrations
end

Instance Method Details

#lookup(symbol) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
# File 'lib/active_remote/type/registry.rb', line 14

def lookup(symbol)
  registration = find_registration(symbol)
  raise ArgumentError, "Unknown type #{symbol.inspect}" unless registration

  registration.typecaster
end

#register(type_name, typecaster) ⇒ Object



10
11
12
# File 'lib/active_remote/type/registry.rb', line 10

def register(type_name, typecaster)
  registrations << registration_klass.new(type_name, typecaster)
end