class Beaconable::BaseBeacon
Attributes
object[R]
object_was[R]
Public Class Methods
new(object, object_was)
click to toggle source
# File lib/beaconable/base_beacon.rb, line 7 def initialize(object, object_was) @object = object @object_was = object_was end
Public Instance Methods
field_changed(field)
click to toggle source
# File lib/beaconable/base_beacon.rb, line 12 def field_changed(field) @field = field @result = field_changed? field self end
from(*values)
click to toggle source
# File lib/beaconable/base_beacon.rb, line 18 def from(*values) return self unless @result @result = values.include? object_was.send(@field) self end
to(*values)
click to toggle source
# File lib/beaconable/base_beacon.rb, line 25 def to(*values) @result && values.include?(object.send(@field)) end
Private Instance Methods
any_field_changed?(*fields)
click to toggle source
# File lib/beaconable/base_beacon.rb, line 39 def any_field_changed?(*fields) fields.each do |field| return true if field_changed?(field) end false end
destroyed_entry?()
click to toggle source
# File lib/beaconable/base_beacon.rb, line 31 def destroyed_entry? object.destroyed? end
field_changed?(field)
click to toggle source
# File lib/beaconable/base_beacon.rb, line 35 def field_changed?(field) object.send(field) != object_was.send(field) end
new_entry?()
click to toggle source
# File lib/beaconable/base_beacon.rb, line 46 def new_entry? object_was.created_at.nil? end