Module: Uniqueable::ClassMethods

Defined in:
lib/uniqueable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#uniqueable_checksObject

Returns the value of attribute uniqueable_checks.



17
18
19
# File 'lib/uniqueable.rb', line 17

def uniqueable_checks
  @uniqueable_checks
end

Instance Method Details

#uniqueable(*values) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/uniqueable.rb', line 18

def uniqueable(*values)
  options = values.last.kind_of?(Hash) ? values.pop : {}
  group = options.delete(:group)
  klass = self
  uniqueable_checks[group] ||= {}
  uniqueable_checks[group][klass] ||= []
  values.each do |value|
    unless options.empty?
      value = {value => options}
    end
    uniqueable_checks[group][klass] << value
  end
  uniqueable_checks[group][klass].uniq!
end