Class: Beaconable::BaseBeacon

Inherits:
Object
  • Object
show all
Defined in:
lib/beaconable/base_beacon.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, object_was) ⇒ BaseBeacon

Returns a new instance of BaseBeacon.



7
8
9
10
# File 'lib/beaconable/base_beacon.rb', line 7

def initialize(object, object_was)
  @object = object
  @object_was = object_was
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



5
6
7
# File 'lib/beaconable/base_beacon.rb', line 5

def object
  @object
end

#object_wasObject (readonly)

Returns the value of attribute object_was.



5
6
7
# File 'lib/beaconable/base_beacon.rb', line 5

def object_was
  @object_was
end

Instance Method Details

#field_changed(field) ⇒ Object



12
13
14
15
16
# File 'lib/beaconable/base_beacon.rb', line 12

def field_changed(field)
  @field = field
  @result = field_changed? field
  self
end

#from(*values) ⇒ Object



18
19
20
21
22
23
# 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) ⇒ Object



25
26
27
# File 'lib/beaconable/base_beacon.rb', line 25

def to(*values)
  @result && values.include?(object.send(@field))
end