9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/permalinkable/permalinkable.rb', line 9
def acts_as_permalinkable(options = {})
send :cattr_accessor, :permalink_options
self.permalink_options = { permalinkable_attribute: :name, permalink_field_name: :permalink,
length: 200, allow_change: false }
self.permalink_options.update(options) if options.is_a?(Hash)
self.permalink_options.freeze
send :include, InstanceMethods
send :after_save, :save_permalink
send :attr_readonly, permalink_options[:permalink_field_name]
send :validates, permalink_options[:permalinkable_attribute], presence: true, length: { minimum: 0 }
end
|