seo_meta 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,27 +20,32 @@ module SeoMeta
20
20
  end
21
21
 
22
22
  def is_seo_meta(options = {})
23
- # Let the base know about SeoMetum
24
- has_one :seo_meta, :class_name => 'SeoMetum',
25
- :foreign_key => :seo_meta_id, :dependent => :destroy,
26
- :conditions => {:seo_meta_type => self.name}
27
-
28
- # Let SeoMetum know about the base
29
- ::SeoMetum.send :belongs_to, self.name.underscore.gsub('/', '_').to_sym,
30
- :class_name => self.name
31
-
32
- # Include the instance methods and extend with the class methods.
33
- self.send :include, ::SeoMeta::InstanceMethods
34
- extend ::SeoMeta::ClassMethods
35
-
36
- # Ensure seo_meta is saved when the model is saved.
37
- after_save :save_meta_tags
38
-
39
- # Delegate both the accessor and setters for the fields to :seo_meta
40
- fields = ::SeoMeta.attributes.keys.reject{|field|
41
- self.column_names.map(&:to_sym).include?(field)
42
- }.map{|a| [a, :"#{a}="]}.flatten
43
- fields << {:to => :seo_meta}
44
-
45
- delegate *fields
23
+ if ::SeoMetum.table_exists?
24
+ # Let the base know about SeoMetum
25
+ has_one :seo_meta, :class_name => 'SeoMetum',
26
+ :foreign_key => :seo_meta_id, :dependent => :destroy,
27
+ :conditions => {:seo_meta_type => self.name}
28
+
29
+ # Let SeoMetum know about the base
30
+ ::SeoMetum.send :belongs_to, self.name.underscore.gsub('/', '_').to_sym,
31
+ :class_name => self.name
32
+
33
+ # Include the instance methods and extend with the class methods.
34
+ self.send :include, ::SeoMeta::InstanceMethods
35
+ extend ::SeoMeta::ClassMethods
36
+
37
+ # Ensure seo_meta is saved when the model is saved.
38
+ after_save :save_meta_tags
39
+
40
+ # Delegate both the accessor and setters for the fields to :seo_meta
41
+ fields = ::SeoMeta.attributes.keys.reject{|field|
42
+ self.column_names.map(&:to_sym).include?(field)
43
+ }.map{|a| [a, :"#{a}="]}.flatten
44
+ fields << {:to => :seo_meta}
45
+
46
+ delegate *fields
47
+ else
48
+ warn "[seo_meta] Table does not exist, please create #{::SeoMetum.table_name}."
49
+ warn "[seo_meta] See https://github.com/parndt/seo_meta#readme for instructions."
50
+ end
46
51
  end
@@ -8,7 +8,7 @@ module SeoMeta
8
8
  def seo_meta
9
9
  find_seo_meta_tags || build_seo_meta_tags
10
10
  end
11
-
11
+
12
12
  def attributes
13
13
  super.merge(seo_meta_attributes)
14
14
  end
@@ -17,9 +17,9 @@ module SeoMeta
17
17
  attributes.update(seo_meta_attributes)
18
18
  super
19
19
  end
20
-
20
+
21
21
  def update_attributes(attributes, *args)
22
- attributes.update(seo_meta_attributes) if ::SeoMetum.table_exists?
22
+ attributes.update(seo_meta_attributes)
23
23
  super
24
24
  end
25
25
  end
@@ -34,23 +34,17 @@ module SeoMeta
34
34
 
35
35
  protected
36
36
  def build_seo_meta_tags
37
- if ::SeoMetum.table_exists?
38
- @seo_meta ||= ::SeoMetum.new :seo_meta_type => self.class.name
39
- end
37
+ @seo_meta ||= ::SeoMetum.new :seo_meta_type => self.class.name
40
38
  end
41
39
 
42
40
  def find_seo_meta_tags
43
- if self.persisted? && ::SeoMetum.table_exists?
44
- @seo_meta ||= ::SeoMetum.where(:seo_meta_type => self.class.name,
41
+ @seo_meta ||= ::SeoMetum.where(:seo_meta_type => self.class.name,
45
42
  :seo_meta_id => self.id).first
46
- end
47
43
  end
48
44
 
49
45
  def save_meta_tags
50
- if ::SeoMetum.table_exists?
51
- seo_meta.seo_meta_id ||= self.id
52
- seo_meta.save
53
- end
46
+ seo_meta.seo_meta_id ||= self.id
47
+ seo_meta.save
54
48
  end
55
49
  end
56
50
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: seo_meta
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.2
5
+ version: 1.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Philip Arndt
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-31 00:00:00 +13:00
13
+ date: 2011-04-04 00:00:00 +12:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency