Sha256: 5c2b6260e0f1ab9e4f7315a0339172c93b9ac119890c01d693b66d4afae6bdd3
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
# NB index instances are all internal to zermelo, not user-accessible module Zermelo module Associations class UniqueIndex def initialize(parent_klass, name) @parent_klass = parent_klass @attribute_name = name @backend = parent_klass.send(:backend) @indexers = {} parent_klass.send(:with_index_data, name.to_sym) do |data| @attribute_type = data.type end end def delete_id(id, value) @backend.delete(key, @backend.index_keys(@attribute_type, value).join(':')) end def add_id(id, value) @backend.add(key, @backend.index_keys(@attribute_type, value).join(':') => id) end def move_id(id, value_from, indexer_to, value_to) @backend.move(key, {@backend.index_keys(@attribute_type, value_to).join(':') => id}, indexer_to.key) end def key @indexer ||= Zermelo::Records::Key.new( :klass => @parent_klass, :name => "by_#{@attribute_name}", :type => :hash, :object => :index ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zermelo-1.1.0 | lib/zermelo/associations/unique_index.rb |