Sha256: 6c2f037ca10da99efda44bf6a2058a26545e8bbc97b607a1deae3cf3fbf52532

Contents?: true

Size: 522 Bytes

Versions: 1

Compression:

Stored size: 522 Bytes

Contents

# frozen_string_literal: true

module Beaconable
  class BaseBeacon
    attr_reader :object, :object_was

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

    private

    def field_changed?(field)
      object.send(field) != object_was.send(field)
    end

    def any_field_changed?(*fields)
      fields.each do |field|
        return true if field_changed?(field)
      end
      false
    end

    def new_entry?
      object_was.created_at.nil?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
beaconable-0.1.2 lib/beaconable/base_beacon.rb