Module: Spree::Core::Permalinks::ClassMethods

Defined in:
lib/spree/core/permalinks.rb

Instance Method Summary collapse

Instance Method Details

#find_by_param(value, *args) ⇒ Object



18
19
20
# File 'lib/spree/core/permalinks.rb', line 18

def find_by_param(value, *args)
  send("find_by_#{permalink_field}", value, *args)
end

#find_by_param!(value, *args) ⇒ Object



22
23
24
# File 'lib/spree/core/permalinks.rb', line 22

def find_by_param!(value, *args)
  send("find_by_#{permalink_field}!", value, *args)
end


11
12
13
14
15
16
# File 'lib/spree/core/permalinks.rb', line 11

def make_permalink(options = {})
  options[:field] ||= :permalink
  self.permalink_options = options

  before_validation(on: :create) { save_permalink }
end


26
27
28
# File 'lib/spree/core/permalinks.rb', line 26

def permalink_field
  permalink_options[:field]
end


34
35
36
# File 'lib/spree/core/permalinks.rb', line 34

def permalink_length
  permalink_options[:length] || 9
end


38
39
40
41
# File 'lib/spree/core/permalinks.rb', line 38

def permalink_order
  order = permalink_options[:order]
  "#{order} ASC," if order
end


30
31
32
# File 'lib/spree/core/permalinks.rb', line 30

def permalink_prefix
  permalink_options[:prefix] || ""
end