Module: SpeakingId::ClassMethods

Defined in:
lib/speaking_id/speaking_id.rb

Instance Method Summary collapse

Instance Method Details

#has_random_slug(options = {}) ⇒ Object



17
18
19
20
21
# File 'lib/speaking_id/speaking_id.rb', line 17

def has_random_slug(options = {})
  speaking_id(options)

  before_create :create_random_slug
end

#has_slug(source, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/speaking_id/speaking_id.rb', line 7

def has_slug(source, options = {})
  speaking_id(options)

  class_inheritable_accessor :slug_source

  self.slug_source = source

  before_save :create_slug
end

#speaking_id(options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/speaking_id/speaking_id.rb', line 23

def speaking_id(options = {})
  send :include, InstanceMethods

  class_inheritable_accessor :slug_column

  self.slug_column = (options[:column] || :slug).to_s

  validates_uniqueness_of self.slug_column
end