diaspora_federation/test/dummy/app/models/entity.rb
Benjamin Neff b0f6131527
Remove active_record and save models in-memory
Simple inmemory "database" to be independent from active_record.
2017-04-05 00:36:52 +02:00

23 lines
404 B
Ruby

class Entity
attr_accessor :author, :guid
attr_reader :entity_type
def initialize(entity_type)
@entity_type = entity_type
@guid = UUID.generate(:compact)
end
def save!
Entity.database[entity_type][guid] = self
end
class << self
def find_by(opts)
database[opts[:entity_type]][opts[:guid]]
end
def database
@database ||= Hash.new({})
end
end
end