Class: Stock
- Inherits:
-
Object
- Object
- Stock
- Defined in:
- lib/porp/stock.rb,
lib/porp/stock/status.rb,
lib/porp/stock/holder.rb,
lib/porp/stock/entity.rb,
lib/porp/stock/holding.rb,
lib/porp/stock/director.rb,
lib/porp/stock/movement.rb,
lib/porp/stock/sourcedest.rb,
lib/porp/stock/movementtarget.rb
Overview
Porp - The Prototype Open Retail Platform
Copyright (c) 2010 Phil Stewart
License: MIT (see LICENSE file)
Defined Under Namespace
Classes: Director, Entity, Holder, Holding, HoldingEntry, MiscTarget, Movement, MovementTarget, NullTarget, SourceDest, Status
Instance Attribute Summary (collapse)
-
- (Object) entity
readonly
Returns the value of attribute entity.
Class Method Summary (collapse)
-
+ (Object) [](id)
A Stock instance for the stock entity identified by id.
-
+ (Stock) create(description = "", opts = {})
Creates a new item of stock, including the entity and all holdings, ensuring all dependencies are met i.e.
-
+ (Object) find_by_plu(plu_value)
Find an item of stock by PLU.
Instance Method Summary (collapse)
-
- (Object) id
The ID of the associated entity.
-
- (Stock) initialize(entity = nil)
constructor
A new instance of Stock.
Constructor Details
- (Stock) initialize(entity = nil)
A new instance of Stock
56 57 58 |
# File 'lib/porp/stock.rb', line 56 def initialize(entity = nil) @entity = entity end |
Instance Attribute Details
- (Object) entity (readonly)
Returns the value of attribute entity
20 21 22 |
# File 'lib/porp/stock.rb', line 20 def entity @entity end |
Class Method Details
+ (Object) [](id)
A Stock instance for the stock entity identified by id
23 24 25 26 27 28 29 30 |
# File 'lib/porp/stock.rb', line 23 def self.[](id) entity = Entity[id] if !entity.nil? self.new(Entity[id]) else nil end end |
+ (Stock) create(description = "", opts = {})
Creates a new item of stock, including the entity and all holdings, ensuring all dependencies are met i.e. all targets, holders, and statuses
49 50 51 52 53 54 |
# File 'lib/porp/stock.rb', line 49 def self.create(description = "", opts = {}) raise Orp::NoHoldersSpecified if opts[:holders].nil? raise Orp::NoStatusesSpecified if opts[:statuses].nil? self.new(Director.(description, opts)) end |
+ (Object) find_by_plu(plu_value)
Find an item of stock by PLU
33 34 35 36 37 38 39 40 |
# File 'lib/porp/stock.rb', line 33 def self.find_by_plu(plu_value) entity = Entity.find_by_plu(plu_value) if !entity.nil? self.new(entity) else nil end end |
Instance Method Details
- (Object) id
The ID of the associated entity
61 62 63 |
# File 'lib/porp/stock.rb', line 61 def id entity.id end |