Module: MLS::Slugger::ActiveRecordBaseSluggerExtension::ClassMethods
- Defined in:
- lib/mls.rb
Instance Method Summary collapse
Instance Method Details
#find(*ids) ⇒ Object
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/mls.rb', line 101 def find(*ids) friendly = -> (id) { id.respond_to?(:to_i) && id.to_i.to_s != id.to_s } return super if ids.size > 1 || !ids.all? { |x| friendly.call(x) } if ids.first.include?("@") self.filter(email_addresses: {address: ids.first}).first else find_by_slug!(ids.first) end end |
#slug(method, options = {}, &block) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/mls.rb', line 93 def slug(method, ={}, &block) = .with_indifferent_access [:trigger] ||= :after_save self.slugger = { :proc => method || block, :options => } self.send([:trigger], :set_slug) self.send(:include, Slugger::History) if [:history] end |