Sha256: b796c2c6091780db685961896ec4a3a93a853da191245e9728f118f5118bf4f6

Contents?: true

Size: 541 Bytes

Versions: 1

Compression:

Stored size: 541 Bytes

Contents

class Retailer < ActiveRecord::Base
  
  validates_presence_of :name, :address, :city, :state, :zipcode
  
  [:address2, :phone, :email].each do |property|
    define_method "has_#{property.to_s}?" do
      val = self.send property
      !(val.nil? || val.empty?)
    end
  end
  
  def has_url?
    (self.url.nil? || self.url.empty?) && self.url != "http://" 
  end
  

  def url=(value)
    val = value.strip.downcase
    if val.match(/^http(s)?:\/\//) == nil
      val = "http://" + val
    end
    write_attribute :url, val
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_retailers-0.40.0.1 app/models/retailer.rb