Module: Spree::Core::Permalinks::ClassMethods
- Defined in:
- lib/spree/core/permalinks.rb
Instance Method Summary collapse
- #find_by_param(value, *args) ⇒ Object
- #find_by_param!(value, *args) ⇒ Object
- #make_permalink(options = {}) ⇒ Object
- #permalink_field ⇒ Object
- #permalink_length ⇒ Object
- #permalink_order ⇒ Object
- #permalink_prefix ⇒ Object
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 |
#make_permalink(options = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/spree/core/permalinks.rb', line 13 def make_permalink(={}) [:field] ||= :permalink self. = before_validation(:on => :create) { save_permalink } end |
#permalink_field ⇒ Object
28 29 30 |
# File 'lib/spree/core/permalinks.rb', line 28 def permalink_field [:field] end |
#permalink_length ⇒ Object
36 37 38 |
# File 'lib/spree/core/permalinks.rb', line 36 def permalink_length [:length] || 9 end |
#permalink_order ⇒ Object
40 41 42 43 |
# File 'lib/spree/core/permalinks.rb', line 40 def permalink_order order = [:order] "#{order} ASC," if order end |
#permalink_prefix ⇒ Object
32 33 34 |
# File 'lib/spree/core/permalinks.rb', line 32 def permalink_prefix [:prefix] || "" end |