Sha256: 63af2d2ea771f2c541fa5fec6998c41cc3ca474e042c1e7f497909ffc2067316

Contents?: true

Size: 736 Bytes

Versions: 6

Compression:

Stored size: 736 Bytes

Contents

class Shop < ActiveRecord::Base

  before_validation :sanitize_twitter_handle, if: :twitter_handle

  validates :from_email,      email: true, allow_blank: false

  validates_format_of :facebook_url, with: URI::regexp, allow_blank: true

  validates_presence_of :name, :theme, :time_zone, :default_creditcard_action
  validates_inclusion_of :default_creditcard_action,  in: %W( authorize purchase )
  validates_numericality_of :tax_percentage, greater_than_or_equal_to: 0, less_than: 100

  class << self
    alias_method :current, :first
  end

  def twitter_url
    twitter_handle.blank? ? nil : "http://twitter.com/#{twitter_handle}"
  end

  private

    def sanitize_twitter_handle
      twitter_handle.gsub!(/^@/, '')
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nimbleshop_core-0.0.1.rc6 app/models/shop.rb
nimbleshop_core-0.0.1.rc5 app/models/shop.rb
nimbleshop_core-0.0.1.rc4 app/models/shop.rb
nimbleshop_core-0.0.1.rc3 app/models/shop.rb
nimbleshop_core-0.0.1.rc2 app/models/shop.rb
nimbleshop_core-0.0.1.rc1 app/models/shop.rb