Sha256: 73e6c724c7bbe464eab928f7f1df591f92b09e789c9a29ad5fd9c4fd985c27c6

Contents?: true

Size: 810 Bytes

Versions: 11

Compression:

Stored size: 810 Bytes

Contents

# -*- encoding : utf-8 -*-
class Card
  class Change < ActiveRecord::Base
    belongs_to :action, foreign_key: :card_action_id, inverse_of: :card_changes

    def field=(value)
      write_attribute(:field, Card::TRACKED_FIELDS.index(value.to_s))
    end

    def field
      Card::TRACKED_FIELDS[read_attribute(:field)]
    end

    def self.delete_actionless
      Card::Change.where(
        "card_action_id NOT IN (?)",
        Card::Action.pluck("id"),
      ).delete_all
    end

    def find_by_field_name(value)
      index = value.is_a?(Integer) ? value : Card::TRACKED_FIELDS.index(value.to_s)
      find_by_field(index)
    end

    def self.find_by_field_name(value)
      index = value.is_a?(Integer) ? value : Card::TRACKED_FIELDS.index(value.to_s)
      find_by_field(index)
    end
  end
end


Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
card-1.17.1 mod/01_history/lib/card/change.rb
card-1.17.0 mod/01_history/lib/card/change.rb
card-1.16.15 mod/01_history/lib/card/change.rb
card-1.16.14 mod/01_history/lib/card/change.rb
card-1.16.13 mod/01_history/lib/card/change.rb
card-1.16.12 mod/01_history/lib/card/change.rb
card-1.16.11 mod/01_history/lib/card/change.rb
card-1.16.10 mod/01_history/lib/card/change.rb
card-1.16.9 mod/01_history/lib/card/change.rb
card-1.16.8 mod/01_history/lib/card/change.rb
card-1.16.7 mod/01_history/lib/card/change.rb