Sha256: 6110b2ee488e00d01cc590ddd3a47c559c956f3bd5d4cdb4dc47cc6d6a6e156b

Contents?: true

Size: 805 Bytes

Versions: 1

Compression:

Stored size: 805 Bytes

Contents

class WeWorkRemotely::Job
  attr_accessor :id, :company, :name, :description, :published_date, :url, :category

  @@all = []

  def initialize(id: nil, company: nil, name: nil, description: nil, published_date: nil, url: nil, category: nil)
    @id = id if id
    @name = name
    @published_date = published_date if published_date
    @url = url if url
    @description = description if description
    @company = WeWorkRemotely::Company.find_or_create_by_name(company) if company
    @company.add_job(self)
    @category = WeWorkRemotely::Category.find_or_create_by_name(category) if category
    @category.add_job(self)
    @@all << self
  end

  def self.all
    @@all
  end

  def self.find_by_id(id)
    self.all.detect { |job| job.id == id }
  end

  def self.destroy_all
    @@all.clear
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
weworkremotely-1.3.3 lib/weworkremotely/job.rb