Class: AllFutures
- Inherits:
-
ActiveEntity::Base
- Object
- ActiveEntity::Base
- AllFutures
- Defined in:
- lib/all_futures/all_futures.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #[]=(attr_name, value) ⇒ Object
-
#initialize(attributes = {}) ⇒ AllFutures
constructor
A new instance of AllFutures.
- #save ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ AllFutures
Returns a new instance of AllFutures.
4 5 6 7 8 9 10 |
# File 'lib/all_futures/all_futures.rb', line 4 def initialize(attributes={}) super unless @id @id = SecureRandom.uuid save end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/all_futures/all_futures.rb', line 2 def id @id end |
Class Method Details
.find(id) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/all_futures/all_futures.rb', line 22 def self.find(id) raise ArgumentError unless id json = Kredis.json("#{name}:#{id}").value raise ActiveRecord::RecordNotFound unless json new json.merge(id: id) end |
Instance Method Details
#[]=(attr_name, value) ⇒ Object
12 13 14 15 |
# File 'lib/all_futures/all_futures.rb', line 12 def []=(attr_name, value) super save end |
#save ⇒ Object
17 18 19 20 |
# File 'lib/all_futures/all_futures.rb', line 17 def save Kredis.json("#{self.class.name}:#{@id}").value = self.attributes changes_applied end |