daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class PurchaseOrderStatus
  2.   attr_accessor :id, :name, :symbol
  3.  
  4.   def initialize(options = {})
  5.     options = options.symbolize_keys
  6.     @id, @name = options[:id], options[:name]
  7.   end
  8.  
  9.   def symbol
  10.     @name.to_s.downcase.intern
  11.   end
  12.  
  13.   def self.[](value)
  14.     @@statuses.select { |status| status.symbol == value.to_s.downcase.intern }.first
  15.   end
  16.  
  17.   def self.find(id)
  18.     @@statuses.select { |status| status.id.to_s == id.to_s }.first
  19.   end
  20.  
  21.   def self.find_all
  22.     @@statuses.dup
  23.   end
  24.  
  25.   # 1 Pending
  26.   # 2 Accepted
  27.   # 3 Authorized
  28.   # 4 Ordered
  29.   # 5 Received
  30.   # 6 Invoiced
  31.   # 7 Closed
  32.   @@statuses = [
  33.     PurchaseOrderStatus.new(:id => 1, :symbol => :pending, :name => _('Pending')),
  34.     PurchaseOrderStatus.new(:id => 2, :symbol => :accepted, :name => _('Accepted')),
  35.     PurchaseOrderStatus.new(:id => 3, :symbol => :authorized, :name => _('Authorized')),
  36.     PurchaseOrderStatus.new(:id => 4, :symbol => :ordered, :name => _('Ordered')),
  37.     PurchaseOrderStatus.new(:id => 5, :symbol => :received, :name => _('Received')),
  38.     PurchaseOrderStatus.new(:id => 6, :symbol => :invoiced, :name => _('Invoiced')),
  39.     PurchaseOrderStatus.new(:id => 7, :symbol => :closed, :name => _('Closed'))
  40.   ]
  41. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top