Class: Ehbrs::Observers::Base
- Inherits:
-
Object
- Object
- Ehbrs::Observers::Base
- Includes:
- EacRubyUtils::Listable
- Defined in:
- lib/ehbrs/observers/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#blank_value ⇒ Object
readonly
Returns the value of attribute blank_value.
-
#last_check_time ⇒ Object
readonly
Returns the value of attribute last_check_time.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
- #changing_value?(value) ⇒ Boolean
- #check(value, date = ::Time.required_zone.now) ⇒ Object
- #last_change_time ⇒ Object
- #last_value ⇒ Object
Instance Attribute Details
#blank_value ⇒ Object (readonly)
Returns the value of attribute blank_value.
12 13 14 |
# File 'lib/ehbrs/observers/base.rb', line 12 def blank_value @blank_value end |
#last_check_time ⇒ Object (readonly)
Returns the value of attribute last_check_time.
12 13 14 |
# File 'lib/ehbrs/observers/base.rb', line 12 def last_check_time @last_check_time end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
12 13 14 |
# File 'lib/ehbrs/observers/base.rb', line 12 def records @records end |
Instance Method Details
#changing_value?(value) ⇒ Boolean
28 29 30 31 32 |
# File 'lib/ehbrs/observers/base.rb', line 28 def changing_value?(value) records.if_present(true) do last_value.if_present(value.present?) { |v| v != value } end end |
#check(value, date = ::Time.required_zone.now) ⇒ Object
23 24 25 26 |
# File 'lib/ehbrs/observers/base.rb', line 23 def check(value, date = ::Time.required_zone.now) @last_check_time = date send("check_with_blank_value_#{blank_value}", value, date) end |
#last_change_time ⇒ Object
34 35 36 |
# File 'lib/ehbrs/observers/base.rb', line 34 def last_change_time records.last.if_present(&:time) end |
#last_value ⇒ Object
38 39 40 |
# File 'lib/ehbrs/observers/base.rb', line 38 def last_value records.last.if_present(&:value) end |