dejavu 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/dejavu.rb +13 -7
  3. data/lib/dejavu/version.rb +1 -1
  4. metadata +20 -31
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fbb81a5ff3b1cf9d39387fdbbcdec19200fe4c26
4
+ data.tar.gz: ec6ed928e5e3a49bafb3c77bb07d772554f268d5
5
+ SHA512:
6
+ metadata.gz: 394f1e9e4f437a5a7af28aaa303ce6fe3f49fe0ef57918d5fa91f02d07b34e550077827ee309ca03743fc7c404ac4b6985a64be5e668e8294907c76053c09a76
7
+ data.tar.gz: 8f7cb8e3f535e287c91ac0b7e850191f98fc98c5f03a3a633da03a465f81fc89f78eb4083c414bbabee96428800ece30afc8b65f75760e067ce54d9efbd811b9
@@ -3,16 +3,14 @@ require "dejavu/version"
3
3
  module Dejavu
4
4
  module ViewHelpers
5
5
  def has_dejavu?(obj)
6
- obj_name = ActiveRecord::Base === obj ? obj.class.model_name.underscore : obj.to_s
7
- !!flash[:"saved_#{obj_name}_for_redisplay"]
6
+ !!flash[:"saved_#{object_name(obj)}_for_redisplay"]
8
7
  end
9
8
 
10
9
  def get_dejavu_for(obj, opts = {})
11
- is_instance = ActiveRecord::Base === obj
12
- model_name = is_instance ? obj.class.model_name.underscore : obj.to_s
10
+ model_name = object_name(obj)
13
11
 
14
12
  if has_dejavu?(obj)
15
- foo = if is_instance
13
+ foo = if is_instance?(obj)
16
14
  if Rails::VERSION::MINOR >= 1
17
15
  obj.assign_attributes(flash[:"saved_#{model_name}_for_redisplay"], :without_protection => true)
18
16
  else
@@ -32,9 +30,17 @@ module Dejavu
32
30
 
33
31
  foo
34
32
  else
35
- is_instance ? obj : obj.to_s.classify.constantize.new
33
+ is_instance?(obj) ? obj : obj.to_s.classify.constantize.new
36
34
  end
37
35
  end
36
+
37
+ def is_instance?(obj)
38
+ ActiveRecord::Base === obj
39
+ end
40
+
41
+ def object_name(obj)
42
+ (is_instance?(obj) ? obj.class.model_name : obj).to_s.underscore
43
+ end
38
44
  end
39
45
 
40
46
  module ControllerMethods
@@ -60,7 +66,7 @@ module Dejavu
60
66
  attrs[key] = obj.send(key)
61
67
  end
62
68
 
63
- flash[:"saved_#{obj.class.model_name.underscore}_for_redisplay"] = attrs
69
+ flash[:"saved_#{object_name(obj)}_for_redisplay"] = attrs
64
70
  end
65
71
 
66
72
  private
@@ -1,3 +1,3 @@
1
1
  module Dejavu
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dejavu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Roger Campos
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-28 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '3.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec-rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '2.7'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '2.7'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: capybara
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.1.1
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.1.1
62
55
  description: Remember your object after a redirect
@@ -66,9 +59,9 @@ executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
- - .gitignore
70
- - .rspec
71
- - .travis.yml
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
72
65
  - Gemfile
73
66
  - README.md
74
67
  - Rakefile
@@ -152,32 +145,28 @@ files:
152
145
  - test_app/vendor/plugins/.gitkeep
153
146
  homepage: https://github.com/rogercampos/dejavu
154
147
  licenses: []
148
+ metadata: {}
155
149
  post_install_message:
156
150
  rdoc_options: []
157
151
  require_paths:
158
152
  - lib
159
153
  required_ruby_version: !ruby/object:Gem::Requirement
160
- none: false
161
154
  requirements:
162
- - - ! '>='
155
+ - - ">="
163
156
  - !ruby/object:Gem::Version
164
157
  version: '0'
165
- segments:
166
- - 0
167
- hash: 995488367
168
158
  required_rubygems_version: !ruby/object:Gem::Requirement
169
- none: false
170
159
  requirements:
171
- - - ! '>='
160
+ - - ">="
172
161
  - !ruby/object:Gem::Version
173
162
  version: '0'
174
- segments:
175
- - 0
176
- hash: 995488367
177
163
  requirements: []
178
164
  rubyforge_project:
179
- rubygems_version: 1.8.24
165
+ rubygems_version: 2.2.2
180
166
  signing_key:
181
- specification_version: 3
167
+ specification_version: 4
182
168
  summary: Remember your object after a redirect
183
- test_files: []
169
+ test_files:
170
+ - spec/integration/dejavu_spec.rb
171
+ - spec/spec_helper.rb
172
+ - spec/support/fields.rb