dynamic_models 0.4.8 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.8
1
+ 0.5.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dynamic_models"
8
- s.version = "0.4.8"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Craig Ulliott"]
12
- s.date = "2012-10-20"
12
+ s.date = "2012-12-21"
13
13
  s.description = "Methods to get and build models directly from parameters. Useful for DRYing up code, specifically very dynamic code for things like admin tools."
14
14
  s.email = "craigulliott@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -5,24 +5,27 @@ module DynamicModelActiveRecordExtensions
5
5
  end
6
6
 
7
7
  def sti_model?
8
+ return false if sti_parent_class == ActiveRecord::Base
8
9
  attribute_names.include? "type"
9
10
  end
10
11
 
11
12
  # for creating routes which are based on the parent class
12
13
  def sti_parent_class
13
- self.class.parent
14
+ self.class.superclass
14
15
  end
15
16
 
16
17
  module ClassMethods
17
18
 
18
19
  # if this class has a type attribute, then it is a model which is using single table inheritance
20
+ # if it is the base class for STI, its parent will be ActiveRecord::Base -- if using AR.
19
21
  def sti_model?
22
+ return false if sti_parent_class == ActiveRecord::Base
20
23
  attribute_names.include? "type"
21
24
  end
22
25
 
23
26
  # for creating routes which are based on the parent class
24
27
  def sti_parent_class
25
- self.parent
28
+ self.superclass
26
29
  end
27
30
 
28
31
  end
@@ -35,7 +35,7 @@ module DynamicModels
35
35
  def model_class
36
36
  klass = model_name.camelize.constantize
37
37
  if sti_model?
38
- raise "you can only pass a type which descends from #{params[:controller]}" unless klass.sti_model? and klass.parent == base_model_class
38
+ raise "you can only pass a type which descends from #{params[:controller]}" unless klass.sti_model? and klass.superclass == base_model_class
39
39
  end
40
40
  klass
41
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-20 00:00:00.000000000 Z
12
+ date: 2012-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  segments:
113
113
  - 0
114
- hash: -2633725406399149360
114
+ hash: 2841165962043228743
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements: