Module: Conflow::Redis::Findable::ClassMethods
- Defined in:
- lib/conflow/redis/findable.rb
Overview
Adds .find method which accepts ID and returns model of proper (sub)type
Instance Method Summary collapse
Instance Method Details
#find(id) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/conflow/redis/findable.rb', line 19 def find(id) class_name = ValueField.new(format(key_template + ":type", id: id)).value raise ::Redis::CommandError, "#{name} with ID #{id} doesn't exist" unless class_name Object.const_get(class_name).new(id) end |