marks 0.0.9 → 0.0.10

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: 997ae105ecd828bf77166e9fe5c8944c68a12187
4
- data.tar.gz: 1b96ae4a38fe0a4e0edefefc806f50eb3775a0be
3
+ metadata.gz: 1e86462ca450799da8d9cc00a1e189703a7e20ed
4
+ data.tar.gz: 3c4bf861b0d599b2f78e1c590aa3edcab2492bea
5
5
  SHA512:
6
- metadata.gz: 638f84c0b05ae1d2746bab348e3dab5870c43efb99f179444c57e28adda4a4e4fa4a13b9296b7af44b354612fb3873b775fae021603afae637e72928f9507e38
7
- data.tar.gz: 0ac089adb5ece388616f8f2a4be8facee2b878d53ef66b4952189329e7480e65a140e9fd4a9a2cbca9666d50ef99ddf4d3b66153382696b4c16230eaf111d7a0
6
+ metadata.gz: 2b1604676f45f4152e59d2e38f432eec222eafed0d3cedce2911d57f49f9eb5c967a0b8bce8517efa8ca444bec4e0e9c0dde437648166e32edfe5c5f201b0ca9
7
+ data.tar.gz: 4755d17d2d6c7537fff745b08b138ccd7377d285918739a18e58ee447f8b22e5b0da8995b299dd53eea4cf4755e2c909fc5444118a5b5cb76dcbb8a8e675ba9d
@@ -21,19 +21,29 @@ module Marks
21
21
  define_method :'marks?' do |markable, mark|
22
22
  classified_mark = mark.to_s.classify
23
23
  raise ArgumentError unless types.map { |t| t.to_s.classify }.include?(classified_mark)
24
- outgoing_marks.where(mark_type: classified_mark, markable_type: markable.class.table_name.classify, markable_id: markable).any?
24
+ if markable.has_attribute?('type')
25
+ markable_type = markable.class.base_class.name
26
+ else
27
+ markable_type = markable.class.name
28
+ end
29
+ outgoing_marks.where(mark_type: classified_mark, markable_type: markable_type, markable_id: markable).any?
25
30
  end
26
31
 
27
32
  define_method :'unmarks' do |markable, mark|
28
33
  classified_mark = mark.to_s.classify
29
34
  raise ArgumentError unless types.map { |t| t.to_s.classify }.include?(classified_mark)
30
- outgoing_marks.where(mark_type: classified_mark, markable_type: markable.class.table_name.classify, markable_id: markable).destroy_all
35
+ if markable.has_attribute?('type')
36
+ markable_type = markable.class.base_class.name
37
+ else
38
+ markable_type = markable.class.name
39
+ end
40
+ outgoing_marks.where(mark_type: classified_mark, markable_type: markable_type, markable_id: markable).destroy_all
31
41
  end
32
42
 
33
43
  define_method :'markings' do |markable_class, mark|
34
44
  classified_mark = mark.to_s.classify
35
45
  raise ArgumentError unless types.map { |t| t.to_s.classify }.include?(classified_mark)
36
- outgoing_marks.where(mark_type: classified_mark, markable_type: markable_class.to_s.constantize.table_name.classify)
46
+ outgoing_marks.where(mark_type: classified_mark, markable_type: markable_class.name)
37
47
  end
38
48
  end
39
49
  end
@@ -1,3 +1,3 @@
1
1
  module Marks
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Ihara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-26 00:00:00.000000000 Z
11
+ date: 2013-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  version: '0'
105
105
  requirements: []
106
106
  rubyforge_project:
107
- rubygems_version: 2.0.2
107
+ rubygems_version: 2.0.3
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: An engine that enable you to mark any ActiveRecord model as many as you like