Sha256: ed76cd29560b4fb97f0a52a1a628aa9e9b958cf7790f1171301f03963227458e

Contents?: true

Size: 541 Bytes

Versions: 3

Compression:

Stored size: 541 Bytes

Contents

module FrontEndBuilds
  class App < ActiveRecord::Base
    if defined?(ProtectedAttributes) || ::ActiveRecord::VERSION::MAJOR < 4
      attr_accessible :name
    end

    has_many :builds, class_name: 'FrontEndBuilds::Build'

    validates :name, presence: true
    validates :api_key, presence: true

    before_validation :ensure_api_key!

    def ensure_api_key!
      self.api_key = SecureRandom.uuid if api_key.blank?
    end

    def find_best_build
      FrontEndBuilds::Build.find_best({
        app: self
      })
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
front_end_builds-0.0.13 app/models/front_end_builds/app.rb
front_end_builds-0.0.12 app/models/front_end_builds/app.rb
front_end_builds-0.0.11 app/models/front_end_builds/app.rb