acts_as_metable 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a70373b977cf7b9662f387d7c5dadaa1b5ba5cb
4
- data.tar.gz: e57d271747a12beef70ab24464cc69ce91e519eb
3
+ metadata.gz: afb3211c561facc4b0984b62348e98a639e14cf6
4
+ data.tar.gz: c0ac35d0be537bff04532a0a0194ebf954dc1142
5
5
  SHA512:
6
- metadata.gz: 71c3036e885fd1207827561319a7e19fc5714d5975966ab1b54cb1340225c6899d6002ca84138f97e4bd314e6c023d2333f010d2d2c6f7da869e50cea9995927
7
- data.tar.gz: 04e4055f21679724a01d325afc84fd14a2b88ad1356b1d4dc42c0fe1ad83e0164e18e329dbb00ec0ba8f9fb2fb0a032d71a21b3bd3d421a870c85a127751d0ca
6
+ metadata.gz: a6922403915cacec2ca50d1814be6ffdd779cca63dcfd615d25063fd307e06cb485d703b2cda8675c1f78435ae5cec31e91358407dda25d82b0b4d4ad080f529
7
+ data.tar.gz: 3d4b22eaaef74422479ec34818ec12662149fa76f6e0aa907582e00c1a68dde852ceab03d4a83abe28a7304bcce0bc5b5b74cfd96b9c5937c76abc64e818ad01
@@ -1,5 +1,9 @@
1
1
  module ActsAsMetable
2
2
  class Tag < ActiveRecord::Base
3
3
  belongs_to :metable, polymorphic: true
4
+
5
+ validates_presence_of :metable_id, if: -> (tag) { tag.metable_type.present? }
6
+ validates_presence_of :metable_type, if: -> (tag) { tag.metable_id.present? }
7
+ validates_presence_of :uid, if: -> (tag) { tag.metable_id.blank? || tag.metable_type.blank? }
4
8
  end
5
9
  end
@@ -0,0 +1,6 @@
1
+ class AddUidToActsAsMetableTags < ActiveRecord::Migration
2
+ def change
3
+ add_column :acts_as_metable_tags, :uid, :string
4
+ add_index :acts_as_metable_tags, :uid
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module ActsAsMetable
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -23,6 +23,12 @@ module ActsAsMetable
23
23
  end
24
24
  end
25
25
 
26
+ def add_by_uid uid
27
+ ActsAsMetable::Tag.where(:uid => uid).each do |tag|
28
+ add_tag tag.name, tag.content
29
+ end
30
+ end
31
+
26
32
  def render
27
33
  result = @tags.map do |tag|
28
34
  ActionController::Base.helpers.tag(:meta, name: tag[:name], content: tag[:content])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_metable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Novikov
@@ -50,6 +50,7 @@ files:
50
50
  - Rakefile
51
51
  - app/models/acts_as_metable/tag.rb
52
52
  - db/migrate/20150913104251_create_acts_as_metable_tags.rb
53
+ - db/migrate/20150913142422_add_uid_to_acts_as_metable_tags.rb
53
54
  - lib/acts_as_metable.rb
54
55
  - lib/acts_as_metable/engine.rb
55
56
  - lib/acts_as_metable/metable.rb