Class: ActiveRemote::Type::Registry
- Inherits:
-
Object
- Object
- ActiveRemote::Type::Registry
- Defined in:
- lib/active_remote/type/registry.rb
Instance Attribute Summary collapse
-
#registrations ⇒ Object
readonly
Returns the value of attribute registrations.
Instance Method Summary collapse
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #lookup(symbol) ⇒ Object
- #register(type_name, typecaster) ⇒ Object
Constructor Details
#initialize ⇒ Registry
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
#registrations ⇒ Object (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
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 |