Sha256: 441bf360c035f2f4da5bd409bec682c77d51f4eb7b95f57b215d0aeecf24f0da

Contents?: true

Size: 528 Bytes

Versions: 1

Compression:

Stored size: 528 Bytes

Contents

class AllFutures < ActiveEntity::Base
  attr_accessor :id

  def initialize(attributes={})
    super
    unless @id
      @id = SecureRandom.uuid
      save
    end
  end

  def []=(attr_name, value)
    super
    save
  end

  def save
    Kredis.json("#{self.class.name}:#{@id}").value = self.attributes.to_json
    changes_applied
  end

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
all_futures-1.0.2 lib/all_futures/all_futures.rb