has_sti 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/has_sti/active_record_extensions.rb +2 -18
- data/lib/has_sti/exceptions.rb +0 -5
- data/lib/has_sti/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c183ca5515058cba144d0e81c1d17e43519bb585
|
|
4
|
+
data.tar.gz: bd7fe07482e99c5e66455b22fc6bb47578e825b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b6a484d4fef0d6676c43a92ca04c2136d0a1837107b94a259c8ba31c5dba26996b20ed5e893a44374e32b2a67bb706641801056240e96aff36d17ae6c8d080f6
|
|
7
|
+
data.tar.gz: 9a73456e152476e6bf0fd6539e76a5e622bb5bc52f50b6b08029d9518caa49d874319b93077cb63ce816d274a41e67f81a7412c06cda17e66cf232348ce66fd1
|
|
@@ -49,31 +49,15 @@ module HasSti
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def define_scope(klass)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
where(superclass.inheritance_column => class_name(klass))
|
|
52
|
+
define_singleton_method scope_method_name(klass) do
|
|
53
|
+
where(self.inheritance_column => class_name(klass))
|
|
55
54
|
end
|
|
56
55
|
end
|
|
57
56
|
|
|
58
|
-
def superclass_for(klass)
|
|
59
|
-
superclass = constant(klass).superclass
|
|
60
|
-
raise HasSti::Exceptions::NoSuperclassError if superclass.nil? || model_superclasses.include?(superclass)
|
|
61
|
-
|
|
62
|
-
superclass
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def model_superclasses
|
|
66
|
-
[ActiveRecord::Base, Object, BasicObject]
|
|
67
|
-
end
|
|
68
|
-
|
|
69
57
|
def class_name(klass)
|
|
70
58
|
klass.to_s.classify
|
|
71
59
|
end
|
|
72
60
|
|
|
73
|
-
def constant(klass)
|
|
74
|
-
class_name(klass).constantize
|
|
75
|
-
end
|
|
76
|
-
|
|
77
61
|
def helper_method_name(klass)
|
|
78
62
|
"#{klass.to_s.underscore}?"
|
|
79
63
|
end
|
data/lib/has_sti/exceptions.rb
CHANGED
data/lib/has_sti/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: has_sti
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arkadiusz Fal
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
116
116
|
version: '0'
|
|
117
117
|
requirements: []
|
|
118
118
|
rubyforge_project:
|
|
119
|
-
rubygems_version: 2.4.5
|
|
119
|
+
rubygems_version: 2.4.5.1
|
|
120
120
|
signing_key:
|
|
121
121
|
specification_version: 4
|
|
122
122
|
summary: Active Record extension that provides helper methods for Single Table Inheritance
|