# File lib/stringex/acts_as_url.rb, line 29
29:       def acts_as_url(attribute, options = {})
30:         cattr_accessor :attribute_to_urlify
31:         cattr_accessor :scope_for_url
32:         cattr_accessor :url_attribute # The attribute on the DB
33:         cattr_accessor :only_when_blank
34:         cattr_accessor :duplicate_count_separator
35:         cattr_accessor :allow_slash
36:         cattr_accessor :allow_duplicates
37:         cattr_accessor :url_limit
38: 
39:         if options[:sync_url]
40:           before_validation(:ensure_unique_url)
41:         else
42:           if defined?(ActiveModel::Callbacks)
43:             before_validation(:ensure_unique_url, :on => :create)
44:           else
45:             before_validation_on_create(:ensure_unique_url)
46:           end
47:         end
48: 
49:         self.attribute_to_urlify = attribute
50:         self.scope_for_url = options[:scope]
51:         self.url_attribute = options[:url_attribute] || "url"
52:         self.only_when_blank = options[:only_when_blank] || false
53:         self.duplicate_count_separator = options[:duplicate_count_separator] || "-"
54:         self.allow_slash = options[:allow_slash] || false
55:         self.allow_duplicates = options[:allow_duplicates] || false
56:         self.url_limit = options[:limit] || nil
57: 
58:         class_eval "def \#{url_attribute}\nif !new_record? && errors[attribute_to_urlify].present?\nself.class.find(id).send(url_attribute)\nelse\nread_attribute(url_attribute)\nend\nend\n"
59:       end