Class: Dropzone::Profile
- Inherits:
-
RecordBase
- Object
- RecordBase
- Dropzone::Profile
- Includes:
- StateAccumulator
- Defined in:
- lib/dropzone/profile.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#addr ⇒ Object
readonly
Returns the value of attribute addr.
-
#prior_profile ⇒ Object
readonly
Returns the value of attribute prior_profile.
-
#transfer_pkey ⇒ Object
readonly
Returns the value of attribute transfer_pkey.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #closed? ⇒ Boolean
- #found? ⇒ Boolean
-
#initialize(addr) ⇒ Profile
constructor
A new instance of Profile.
Methods included from StateAccumulator
#blockchain, included, #messages
Methods inherited from RecordBase
Constructor Details
#initialize(addr) ⇒ Profile
Returns a new instance of Profile.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dropzone/profile.rb', line 7 def initialize(addr) @addr = addr .reverse.each_with_index do |seller, i| # There is a bit of extra logic if the seller profile was transferred # from elsewhere if i == 0 && seller.transfer_pkey # Load the profile from the prior address and pop it off the stack @prior_profile = self.class.new seller.sender_addr # It's possible the prior profile was invalid break unless @prior_profile.valid? # And it's possible the prior profile was deactivated or not # transferred to us: break unless @prior_profile.transfer_pkey == addr attrs_from @prior_profile else # This prevents a second inbound transfer from happening: next if seller.transfer_pkey == addr # In case they transferred away : @transfer_pkey = seller.transfer_pkey attrs_from seller end break if @transfer_pkey end end |
Instance Attribute Details
#addr ⇒ Object (readonly)
Returns the value of attribute addr.
5 6 7 |
# File 'lib/dropzone/profile.rb', line 5 def addr @addr end |
#prior_profile ⇒ Object (readonly)
Returns the value of attribute prior_profile.
5 6 7 |
# File 'lib/dropzone/profile.rb', line 5 def prior_profile @prior_profile end |
#transfer_pkey ⇒ Object (readonly)
Returns the value of attribute transfer_pkey.
5 6 7 |
# File 'lib/dropzone/profile.rb', line 5 def transfer_pkey @transfer_pkey end |
Instance Method Details
#active? ⇒ Boolean
40 |
# File 'lib/dropzone/profile.rb', line 40 def active?; @transfer_pkey.nil? end |
#closed? ⇒ Boolean
39 |
# File 'lib/dropzone/profile.rb', line 39 def closed?; (@transfer_pkey == 0); end |
#found? ⇒ Boolean
41 |
# File 'lib/dropzone/profile.rb', line 41 def found?; .length > 0; end |