module ScopedId::Concern
Public Instance Methods
generate_next_scoped_ids()
click to toggle source
# File lib/scoped_id/concern.rb, line 34 def generate_next_scoped_ids self.class.scoped_ids_definitions.each do |definition| attr_name = definition.attr_name if send("#{attr_name}").nil? send "#{attr_name}=", send("get_next_scoped_id", definition) end end end
get_next_scoped_id(scoped_id_definition)
click to toggle source
# File lib/scoped_id/concern.rb, line 43 def get_next_scoped_id(scoped_id_definition) attr_name = scoped_id_definition.attr_name scope_attr = scoped_id_definition.scope_attr scope = self.class.where(scope_attr => read_attribute(scope_attr)) current_max_scoped_id = scope.maximum(attr_name) || 0 current_max_scoped_id + 1 end