Class: Nis::Request::PrepareAnnounce
- Inherits:
-
Object
- Object
- Nis::Request::PrepareAnnounce
- Includes:
- Mixin::Struct
- Defined in:
- lib/nis/request/prepare_announce.rb
Overview
Constant Summary collapse
- DEADLINE =
3600
Instance Attribute Summary collapse
-
#keypair ⇒ Nis::Keypair
The current value of keypair.
-
#transaction ⇒ Nis::Struct::Transaction
The current value of transaction.
Instance Method Summary collapse
-
#initialize(transaction, keypair) ⇒ PrepareAnnounce
constructor
A new instance of PrepareAnnounce.
-
#to_hash ⇒ Hash
Attribute and value pairs.
Methods included from Mixin::Struct
Constructor Details
#initialize(transaction, keypair) ⇒ PrepareAnnounce
Returns a new instance of PrepareAnnounce.
12 13 14 15 |
# File 'lib/nis/request/prepare_announce.rb', line 12 def initialize(transaction, keypair) @keypair = keypair @transaction = transaction end |
Instance Attribute Details
#keypair ⇒ Nis::Keypair
Returns the current value of keypair.
5 6 7 |
# File 'lib/nis/request/prepare_announce.rb', line 5 def keypair @keypair end |
#transaction ⇒ Nis::Struct::Transaction
Returns the current value of transaction.
5 6 7 |
# File 'lib/nis/request/prepare_announce.rb', line 5 def transaction @transaction end |
Instance Method Details
#to_hash ⇒ Hash
Returns Attribute and value pairs.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nis/request/prepare_announce.rb', line 18 def to_hash entity = @transaction.clone entity.amount *= 1_000_000 if entity.respond_to?(:amount) if entity.respond_to?(:other_trans) other_trans(entity) end entity.tap do |tx| tx.timeStamp = Nis::Util. tx.deadline = Nis::Util.deadline(DEADLINE) tx.version = Nis::Util.parse_version(tx.network, version(tx)) tx.signer = @keypair.public end entity_hash = entity.to_hash if entity.respond_to?(:has_mosaics?) && !entity.has_mosaics? entity_hash.delete(:mosaics) end if entity.respond_to?(:other_trans) && !entity.other_trans.has_mosaics? entity_hash[:otherTrans].delete(:mosaics) end { transaction: entity_hash, privateKey: @keypair.private } end |