Sha256: 8107023f8ea942f9b6e248fd3ecb2c266fc556bfbcb70643e4a70605a24efbb1

Contents?: true

Size: 523 Bytes

Versions: 2

Compression:

Stored size: 523 Bytes

Contents

module ConfirmedAttributes
  class Control < ActiveRecord::Base
    self.table_name_prefix = "confirmed_attributes_"

    belongs_to :user
    belongs_to :targetable, polymorphic: true

    validates :name, :value, :targetable, presence: true

    def title
      "#{name}: #{value}"
    end

    def verify(attribute_name)
      if targetable.confirmable_attribute?(attribute_name)
        self.name = attribute_name.to_s
        self.value = targetable.send(attribute_name).to_s
        save
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
confirmed_attributes-0.2.0 lib/confirmed_attributes/control.rb
confirmed_attributes-0.1.0 lib/confirmed_attributes/control.rb