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



20
21
22
# File 'lib/spree/core/permalinks.rb', line 20

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

#find_by_param!(value, *args) ⇒ Object



24
25
26
# File 'lib/spree/core/permalinks.rb', line 24

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


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

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

  before_validation(:on => :create) { save_permalink }
end


28
29
30
# File 'lib/spree/core/permalinks.rb', line 28

def permalink_field
  permalink_options[:field]
end


36
37
38
# File 'lib/spree/core/permalinks.rb', line 36

def permalink_length
  permalink_options[:length] || 9
end


40
41
42
43
# File 'lib/spree/core/permalinks.rb', line 40

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


32
33
34
# File 'lib/spree/core/permalinks.rb', line 32

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