enqueue_destroy return if deleted? update_attribute(:deleted, true) Resque.enqueue(ProcessDealerDestroy, self.id) end ! def purging? not purge_queued_at.nil? end ! def self.find_dealers(search_query) dealers = self.scoped dealers = dealers.merge(self.where('name ILIKE ?', "%#{search_query}%")) unless search_query.blank? dealers end ! def import_locations Haystack::AdWords::LocationsImporter.new(self).import end ! def google_campaign_id dynamic_campaign.try(:remote_campaign_id) end ! delegate :display_url, :destination_url, :mobile_bid_adjustment, :mobile_destination_url, to: :dynamic_campaign ! def models_titles_grouped_by_makes models.order(:title).each_with_object({}) do |model, result| result[model.make_title] ||= [] result[model.make_title] << model.title end end ! private ! def assign_templates Haystack::AdTemplates::Generator.new.assign_default_templates_for(self) end ! def adwords_account_missing? has_google_ads? && account_id.blank? end ! end Is this familiar to you?
do |line| description, price = line self.create(description: description, price: price.to_d) end end ! private def download_file Net::HTTP.start("www.my-super-server.com") do |http| response = http.get("/path/to/file.csv") open("my-local-file.csv", "wb") do |file| file.write(response.body) end end end end
do |line| description, price = line self.create(description: description, price: price) end end end ! class SuperDownloader def download_file # Download from interwebs end end !
do |line| description, price = line self.create(description: description, price: price) end end end ! class SuperDownloader def download_file # Download from interwebs end end !
downloader.download_file CSV.foreach(file) do |line| description, price = line self.create(description: description, price: price) end end end ! class SuperDownloader def download_file # Download from interwebs end end ! class S3Downloader < SuperDownloader def download_file # Now we're cool and user S3 to store our inventories end end !
all the FTP connection to download our file end end ! class S3Downloader < GeneralDownloader def download_file # Now we're cool and user S3 to store our inventories end end ! class GeneralDownloader def download_file # get any url and download, more like wget end end
press_power_button obj.on? ? obj.off : obj.on end end ! class TV def on? ; end def on ; end def off ; end end ! class Radio def on? ; end def on ; end def off ; end end