Module: Permalinkable::ClassMethods

Defined in:
lib/permalinkable/permalinkable.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_permalinkable(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/permalinkable/permalinkable.rb', line 7

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)

  send :include, InstanceMethods
  send :after_save, :save_permalink
end


17
18
19
20
21
22
# File 'lib/permalinkable/permalinkable.rb', line 17

def permalink_cipher
  cipher = OpenSSL::Cipher.new('RC4-40')
  cipher.encrypt
  cipher.key = Base64.urlsafe_decode64(Configure.key)
  cipher
end