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
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 |
#make_permalink(options = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/spree/core/permalinks.rb', line 11 def make_permalink( = {}) [:field] ||= :permalink self. = before_validation(on: :create) { save_permalink } end |
#permalink_field ⇒ Object
26 27 28 |
# File 'lib/spree/core/permalinks.rb', line 26 def permalink_field [:field] end |
#permalink_length ⇒ Object
34 35 36 |
# File 'lib/spree/core/permalinks.rb', line 34 def permalink_length [:length] || 9 end |
#permalink_order ⇒ Object
38 39 40 41 |
# File 'lib/spree/core/permalinks.rb', line 38 def permalink_order order = [:order] "#{order} ASC," if order end |
#permalink_prefix ⇒ Object
30 31 32 |
# File 'lib/spree/core/permalinks.rb', line 30 def permalink_prefix [:prefix] || "" end |