Module: Seofy::ActiveRecord::ClassMethods

Defined in:
lib/seofy/active_record.rb

Instance Method Summary collapse

Instance Method Details

#for_seofy(param) ⇒ Object



20
21
22
# File 'lib/seofy/active_record.rb', line 20

def for_seofy(param) 
  self.send("find_by_#{seofy_adapter.column}", param.split("-").last)
end

#for_seofy_with_short_url(param) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/seofy/active_record.rb', line 24

def for_seofy_with_short_url(param) 
  if param.to_s.include?("-") 
    for_seofy(param)
  else 
    self.send("find_by_#{seofy_adapter.column}", param)
  end
end

#init_seofy_config(options = {}) ⇒ Object



11
12
13
14
# File 'lib/seofy/active_record.rb', line 11

def init_seofy_config(options={})
  class_attribute :seofy_config
  self.seofy_config = ::Seofy::Configuration.new(options)
end

#seofy(options = {}) ⇒ Object



4
5
6
7
8
9
# File 'lib/seofy/active_record.rb', line 4

def seofy(options={})
  init_seofy_config(options)
  include ::Seofy::ActiveRecord::InstanceMethods
  before_create :seofy_before_create
  after_create :seofy_after_create
end

#seofy_adapterObject



16
17
18
# File 'lib/seofy/active_record.rb', line 16

def seofy_adapter
  self.seofy_config.adapter
end