gendalf 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.8. Added step model instantination (in terms of attributes values) from WizardModel class instance possible
2
+
1
3
  v0.7. Added @wizard_model assignment on every step
2
4
 
3
5
  v0.6. Extracted current step loading routine to be used outside of the original gem workflow
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ Echoe.new('gendalf') do |p|
5
5
  p.email = 'sky.31338@gmail.com'
6
6
  p.summary = 'Trivial gem to support wizard application style creation.'
7
7
  p.url = 'http://github.com/skywriter/gendalf'
8
- p.runtime_dependencies = ['activemodel', 'actionpack']
8
+ p.runtime_dependencies = ['activemodel >=3.0.4', 'actionpack >=3.0.4']
9
9
  p.development_dependencies = ['echoe']
10
10
  p.retain_gemspec = true
11
11
  end
data/gendalf.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{gendalf}
5
- s.version = "0.7"
5
+ s.version = "0.8"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ivan Kasatenko"]
9
- s.date = %q{2011-03-02}
9
+ s.date = %q{2011-03-09}
10
10
  s.description = %q{Trivial gem to support wizard application style creation.}
11
11
  s.email = %q{sky.31338@gmail.com}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "README.markdown", "lib/controllers/wizard_controller.rb", "lib/extensions/routes.rb", "lib/gendalf.rb", "lib/models/wizard_model.rb"]
@@ -22,17 +22,17 @@ Gem::Specification.new do |s|
22
22
  s.specification_version = 3
23
23
 
24
24
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
- s.add_runtime_dependency(%q<activemodel>, [">= 0"])
26
- s.add_runtime_dependency(%q<actionpack>, [">= 0"])
25
+ s.add_runtime_dependency(%q<activemodel>, [">= 3.0.4"])
26
+ s.add_runtime_dependency(%q<actionpack>, [">= 3.0.4"])
27
27
  s.add_development_dependency(%q<echoe>, [">= 0"])
28
28
  else
29
- s.add_dependency(%q<activemodel>, [">= 0"])
30
- s.add_dependency(%q<actionpack>, [">= 0"])
29
+ s.add_dependency(%q<activemodel>, [">= 3.0.4"])
30
+ s.add_dependency(%q<actionpack>, [">= 3.0.4"])
31
31
  s.add_dependency(%q<echoe>, [">= 0"])
32
32
  end
33
33
  else
34
- s.add_dependency(%q<activemodel>, [">= 0"])
35
- s.add_dependency(%q<actionpack>, [">= 0"])
34
+ s.add_dependency(%q<activemodel>, [">= 3.0.4"])
35
+ s.add_dependency(%q<actionpack>, [">= 3.0.4"])
36
36
  s.add_dependency(%q<echoe>, [">= 0"])
37
37
  end
38
38
  end
@@ -44,7 +44,7 @@ module Gendalf
44
44
 
45
45
  def load_current_step
46
46
  @wizard_model = wizard_model
47
- @step = model.new(params[param_name])
47
+ @step = model.new(params[param_name] || wizard_model)
48
48
  end
49
49
 
50
50
  def wizard_model
@@ -63,19 +63,37 @@ module Gendalf
63
63
 
64
64
  step_model_class.class_eval do
65
65
  def initialize(attributes = {})
66
- return unless attributes.kind_of? Hash
67
66
  if self.respond_to?(:custom_load_attributes)
68
67
  custom_load_attributes attributes
69
- else
70
- load_attributes attributes
68
+ return
71
69
  end
70
+
71
+ puts "#{attributes.inspect}"
72
+
73
+ if attributes.kind_of? WizardModel
74
+ load_attributes_from_wizard_model attributes
75
+ return
76
+ end
77
+
78
+ if attributes.kind_of? Hash
79
+ load_attributes_from_hash attributes
80
+ return
81
+ end
82
+
83
+ raise "Step model class requires initial values to be either Hash or WizardModel instance"
72
84
  end
73
85
 
74
- def load_attributes(attributes)
86
+ def load_attributes_from_hash(attributes)
75
87
  attributes.each do |name, value|
76
88
  send("#{name}=", value)
77
89
  end
78
90
  end
91
+
92
+ def load_attributes_from_wizard_model(model)
93
+ self.class.step_attributes.each do |attribute|
94
+ send("#{attribute}=", model.send(attribute))
95
+ end
96
+ end
79
97
 
80
98
  def persisted?
81
99
  false
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gendalf
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 7
9
- version: "0.7"
8
+ - 8
9
+ version: "0.8"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ivan Kasatenko
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-02 00:00:00 +03:00
17
+ date: 2011-03-09 00:00:00 +03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -25,10 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- hash: 3
28
+ hash: 15
29
29
  segments:
30
+ - 3
30
31
  - 0
31
- version: "0"
32
+ - 4
33
+ version: 3.0.4
32
34
  type: :runtime
33
35
  version_requirements: *id001
34
36
  - !ruby/object:Gem::Dependency
@@ -39,10 +41,12 @@ dependencies:
39
41
  requirements:
40
42
  - - ">="
41
43
  - !ruby/object:Gem::Version
42
- hash: 3
44
+ hash: 15
43
45
  segments:
46
+ - 3
44
47
  - 0
45
- version: "0"
48
+ - 4
49
+ version: 3.0.4
46
50
  type: :runtime
47
51
  version_requirements: *id002
48
52
  - !ruby/object:Gem::Dependency