eitil 1.1.20 → 1.1.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 276d6270d8b18ac77d7ca5eb64524c4a7e00eb7155137d4fe88e5aaa4ef26811
4
- data.tar.gz: 5e4a1db5aa4244dc7b9a5179438ed16d0a4fdc75686642511d2cf8c6d094cbec
3
+ metadata.gz: fcfbc894bc4eedf0e052f4163ddf1c37f668b510a3c50840a9ec569f12ac3aa2
4
+ data.tar.gz: 339468c8001ddca581a733fcccb7714498aa1b200b271852493fca7ae71c7a72
5
5
  SHA512:
6
- metadata.gz: b75dd17f605fe1e8205cf0b412eb82e8f3a618a2516c213172beaec0c46f5a7a49f1e1ea71a5f8ba9479d0c3712bc3c52981c76b072d015270a69407f1df09af
7
- data.tar.gz: b722f1234987f762693afd2e3f92e7ed67b31fbfa4f27cca8583c6999876065a1863d6b66b2e9ad6b548d93af7af033a6ee84c11856154ecfb7954d32a79b19c
6
+ metadata.gz: c1b8b6a8287b19abaaac036badf38a78605f2b5b5e2ed5d3a3826bf193e78b9dbc83d0b9e7a740b9a0cafc8ed18c42971bdf7dd0098361ef58ce34df18af578e
7
+ data.tar.gz: b96b86a0707d073316140829718482025abffca8511784a4ef7e0a9141423a0008a0e77e378d5d6ae8c012e2093f4345f40d8d352d08510b6f353a892ffb39ca
@@ -59,15 +59,15 @@ decorate(dec_item, dec_method: nil, dec_class: nil, **dec_kwargs)
59
59
 
60
60
  ### Configuration
61
61
 
62
- 1. Your decorator classes should inherit from Eitil::ApplicationDecorator.
63
- 2. Your controllers should inherit the module Eitil::ControllerDecorator, through inclusion in a superclass.
64
- 3. If you set controller ivars for each request, you can make them available in your decorators by providing Eitil a method which returns the names of your ivars as an array of symbols:
62
+ 1. Your decorator classes should inherit from EitilWrapper::ApplicationDecorator.
63
+ 2. Your controllers should inherit the module EitilWrapper::ControllerDecorator, through inclusion in a superclass.
64
+ 3. If you set controller ivars for each request, you can make them available in your decorators by providing Eitil with the names of your ivars as an array of symbols:
65
65
 
66
66
  ```ruby
67
67
  # initializers/eitil.rb
68
68
 
69
69
  Eitil.set_config do |config|
70
- config.get_controller_ivars_method = 'API::BaseController.controller_ivars' # => [:user, :env]
70
+ config.controller_ivars = [:user, :env]
71
71
  end
72
72
  ```
73
73
 
@@ -70,8 +70,8 @@ module EitilWrapper
70
70
  became_method = "#{column_name}_became_true"
71
71
 
72
72
  define_method(method_name) do
73
- # changes are present in before_safe, otherwise dispatch to after_save
74
- changes&.present? ? send(becomes_method) : send(became_method)
73
+ return send(becomes_method) if changes&.present?
74
+ return send(became_method) if previous_changes&.present?
75
75
  end
76
76
  end
77
77
 
@@ -99,8 +99,8 @@ module EitilWrapper
99
99
  became_method = "#{column_name}_became_false"
100
100
 
101
101
  define_method(method_name) do
102
- # changes are present in before_safe, otherwise dispatch to after_save
103
- changes&.present? ? send(becomes_method) : send(became_method)
102
+ return send(becomes_method) if changes&.present?
103
+ return send(became_method) if previous_changes&.present?
104
104
  end
105
105
  end
106
106
 
@@ -19,7 +19,7 @@ module EitilWrapper
19
19
  end
20
20
 
21
21
  def inform_no_method_for_decorator_error
22
- message = "Warning: NoMethodError for #{@dec_class}.#{@dec_method}, returned @dec_item instead."
22
+ message = "Warning: NoMethodError for #{@dec_class}##{@dec_method}, returned @dec_item instead."
23
23
  Logger.new("#{Rails.root}/log/decorator_log.log").warn message
24
24
  warn message
25
25
  end
@@ -51,7 +51,7 @@ module EitilWrapper
51
51
  end
52
52
 
53
53
  def controller_ivars
54
- eval(Eitil.get_controller_ivars_method).map do |ivar|
54
+ Eitil.controller_ivars.map do |ivar|
55
55
  { ivar => instance_variable_get("@#{ivar.to_s}") }
56
56
  end.inject &:merge
57
57
  end
data/lib/eitil/railtie.rb CHANGED
@@ -27,7 +27,7 @@ module Eitil
27
27
 
28
28
  end
29
29
 
30
- mattr_accessor :get_controller_ivars_method
30
+ mattr_accessor :controller_ivars
31
31
 
32
32
  def self.set_config(&block)
33
33
  yield self
data/lib/eitil/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Eitil
2
2
 
3
- VERSION = '1.1.20'
3
+ VERSION = '1.1.21'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eitil
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.20
4
+ version: 1.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurriaan Schrofer