Sha256: 67a3648343e4fb0b64a630722027f93819c29583a84c43a6855829c33f753ef3

Contents?: true

Size: 768 Bytes

Versions: 2

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

module Sail
  # Entry
  #
  # The Entry class holds the saved value
  # for settings for each profile. It is
  # a model for representing the N x N
  # relationship between profiles and settings
  class Entry < ApplicationRecord
    belongs_to :setting
    belongs_to :profile
    validates_presence_of :value, :setting, :profile

    scope :by_profile_name, ->(name) { joins(:profile).where("sail_profiles.name = ?", name) }

    def name
      setting.name
    end

    # dirty?
    #
    # dirty? will return true if
    # the entry value is different
    # than the associated setting value.
    # This happens when a setting is changed
    # without saving the profile.
    def dirty?
      value != setting.value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sail-3.0.1 app/models/sail/entry.rb
sail-3.0.0 app/models/sail/entry.rb