Sha256: 5f5dfe5cdb3ece4c118abe72d3358fde040411ab10ce7c26b2feab96b32296cf

Contents?: true

Size: 812 Bytes

Versions: 7

Compression:

Stored size: 812 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

7 entries across 7 versions & 1 rubygems

Version Path
card-1.16.6 mod/01_history/lib/card/change.rb
card-1.16.5 mod/01_history/lib/card/change.rb
card-1.16.4 mod/01_history/lib/card/change.rb
card-1.16.3 mod/01_history/lib/card/change.rb
card-1.16.2 mod/01_history/lib/card/change.rb
card-1.16.1 mod/01_history/lib/card/change.rb
card-1.16.0 mod/01_history/lib/card/change.rb