Class: Rosetta::Deserializers::Base
- Inherits:
-
Object
- Object
- Rosetta::Deserializers::Base
- Defined in:
- lib/rosetta/deserializers/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object (also: #deserialize)
-
#initialize(input) ⇒ Base
constructor
A new instance of Base.
- #to_proc ⇒ Object
Constructor Details
#initialize(input) ⇒ Base
Returns a new instance of Base.
28 29 30 |
# File 'lib/rosetta/deserializers/base.rb', line 28 def initialize(input) @input = input.dup.freeze end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
9 10 11 |
# File 'lib/rosetta/deserializers/base.rb', line 9 def input @input end |
Class Method Details
.call(input) ⇒ Object
18 19 20 |
# File 'lib/rosetta/deserializers/base.rb', line 18 def call(input) new(input).call end |
.deserialize ⇒ Object
21 22 23 |
# File 'lib/rosetta/deserializers/base.rb', line 21 def call(input) new(input).call end |
.inherited(new_serializer) ⇒ Object
12 13 14 15 16 |
# File 'lib/rosetta/deserializers/base.rb', line 12 def inherited(new_serializer) key = new_serializer.name.match(/^(.*?)(Deserializer)?$/)[1] key = key.split("::").last Deserializers.register(key.underscore.to_sym, new_serializer) end |
.to_proc ⇒ Object
23 24 25 |
# File 'lib/rosetta/deserializers/base.rb', line 23 def to_proc proc { |*args, &block| self.call(*args, &block) } end |
Instance Method Details
#call ⇒ Object Also known as: deserialize
32 33 34 |
# File 'lib/rosetta/deserializers/base.rb', line 32 def call raise NotImplementedError end |
#to_proc ⇒ Object
37 38 39 |
# File 'lib/rosetta/deserializers/base.rb', line 37 def to_proc proc { |*args, &block| self.call(*args, &block) } end |