dynamic_models 0.1.2 → 0.2.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.1.2
1
+ 0.2.0
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{dynamic_models}
8
- s.version = "0.1.2"
7
+ s.name = "dynamic_models"
8
+ s.version = "0.2.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 = %q{2011-07-08}
13
- s.description = %q{Methods to get and build models directly from parameters. Useful for DRYing up code, specifically very dynamic code for things like admin tools.}
14
- s.email = %q{craigulliott@gmail.com}
12
+ s.date = "2011-11-20"
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
+ s.email = "craigulliott@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.rdoc"
@@ -29,11 +29,11 @@ Gem::Specification.new do |s|
29
29
  "test/helper.rb",
30
30
  "test/test_dynamic_models.rb"
31
31
  ]
32
- s.homepage = %q{http://github.com/craigulliott/dynamic_models}
32
+ s.homepage = "http://github.com/craigulliott/dynamic_models"
33
33
  s.licenses = ["MIT"]
34
34
  s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.6.2}
36
- s.summary = %q{Adds some methods to ActionController to build models dynamically}
35
+ s.rubygems_version = "1.8.10"
36
+ s.summary = "Adds some methods to ActionController to build models dynamically"
37
37
 
38
38
  if s.respond_to? :specification_version then
39
39
  s.specification_version = 3
@@ -14,11 +14,19 @@ module DynamicModels
14
14
  def model_name
15
15
  params[:controller].split('/').last.singularize
16
16
  end
17
+
18
+ # plural form of the model name from the controller
19
+ def plural_model_name
20
+ params[:controller].split('/').last
21
+ end
17
22
 
18
23
  # returns a new model, it can be set with an optional hash
19
24
  def new_model(defaults = {})
20
- new_model = model_name.camelize.constantize.new(defaults)
21
- new_model.send("#{parent_model.class.name.underscore}=", parent_model) if parent_model
25
+ if parent_model
26
+ new_model = parent_model.send(plural_model_name).build(defaults)
27
+ else
28
+ new_model = model_name.camelize.constantize.new(defaults)
29
+ end
22
30
  return new_model
23
31
  end
24
32
 
metadata CHANGED
@@ -1,72 +1,69 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: dynamic_models
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
4
5
  prerelease:
5
- version: 0.1.2
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Craig Ulliott
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-07-08 00:00:00 -05:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-20 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: shoulda
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2168246500 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :development
25
23
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2168246500
25
+ - !ruby/object:Gem::Dependency
28
26
  name: bundler
29
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &2168245300 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
29
+ requirements:
32
30
  - - ~>
33
- - !ruby/object:Gem::Version
31
+ - !ruby/object:Gem::Version
34
32
  version: 1.0.0
35
33
  type: :development
36
34
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *2168245300
36
+ - !ruby/object:Gem::Dependency
39
37
  name: jeweler
40
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &2168244340 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
40
+ requirements:
43
41
  - - ~>
44
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
45
43
  version: 1.6.0
46
44
  type: :development
47
45
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *2168244340
47
+ - !ruby/object:Gem::Dependency
50
48
  name: rcov
51
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &2168243280 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
57
55
  type: :development
58
56
  prerelease: false
59
- version_requirements: *id004
60
- description: Methods to get and build models directly from parameters. Useful for DRYing up code, specifically very dynamic code for things like admin tools.
57
+ version_requirements: *2168243280
58
+ description: Methods to get and build models directly from parameters. Useful for
59
+ DRYing up code, specifically very dynamic code for things like admin tools.
61
60
  email: craigulliott@gmail.com
62
61
  executables: []
63
-
64
62
  extensions: []
65
-
66
- extra_rdoc_files:
63
+ extra_rdoc_files:
67
64
  - LICENSE.txt
68
65
  - README.rdoc
69
- files:
66
+ files:
70
67
  - .document
71
68
  - Gemfile
72
69
  - Gemfile.lock
@@ -78,36 +75,32 @@ files:
78
75
  - lib/dynamic_models.rb
79
76
  - test/helper.rb
80
77
  - test/test_dynamic_models.rb
81
- has_rdoc: true
82
78
  homepage: http://github.com/craigulliott/dynamic_models
83
- licenses:
79
+ licenses:
84
80
  - MIT
85
81
  post_install_message:
86
82
  rdoc_options: []
87
-
88
- require_paths:
83
+ require_paths:
89
84
  - lib
90
- required_ruby_version: !ruby/object:Gem::Requirement
85
+ required_ruby_version: !ruby/object:Gem::Requirement
91
86
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- hash: 2503576804666409791
96
- segments:
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ segments:
97
92
  - 0
98
- version: "0"
99
- required_rubygems_version: !ruby/object:Gem::Requirement
93
+ hash: 173425440645346233
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
95
  none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: "0"
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
105
100
  requirements: []
106
-
107
101
  rubyforge_project:
108
- rubygems_version: 1.6.2
102
+ rubygems_version: 1.8.10
109
103
  signing_key:
110
104
  specification_version: 3
111
105
  summary: Adds some methods to ActionController to build models dynamically
112
106
  test_files: []
113
-