Class: Nis::Request::Announce
- Inherits:
-
Object
- Object
- Nis::Request::Announce
- Includes:
- Mixin::Struct
- Defined in:
- lib/nis/request/announce.rb
Overview
Constant Summary collapse
- DEADLINE =
3600
Instance Attribute Summary collapse
-
#data ⇒ String
The current value of data.
-
#keypair ⇒ Object
Returns the value of attribute keypair.
-
#signature ⇒ String
writeonly
The newly set value.
-
#transaction ⇒ Object
Returns the value of attribute transaction.
Instance Method Summary collapse
-
#initialize(transaction, keypair) ⇒ Announce
constructor
A new instance of Announce.
-
#to_hash ⇒ Hash
Attribute and value pairs.
Methods included from Mixin::Struct
Constructor Details
#initialize(transaction, keypair) ⇒ Announce
Returns a new instance of Announce.
12 13 14 15 |
# File 'lib/nis/request/announce.rb', line 12 def initialize(transaction, keypair) @keypair = keypair @transaction = transaction end |
Instance Attribute Details
#data ⇒ String
Returns the current value of data.
5 6 7 |
# File 'lib/nis/request/announce.rb', line 5 def data @data end |
#keypair ⇒ Object
Returns the value of attribute keypair.
8 9 10 |
# File 'lib/nis/request/announce.rb', line 8 def keypair @keypair end |
#signature=(value) ⇒ String
Returns the newly set value.
5 6 7 |
# File 'lib/nis/request/announce.rb', line 5 def signature=(value) @signature = value end |
#transaction ⇒ Object
Returns the value of attribute transaction.
8 9 10 |
# File 'lib/nis/request/announce.rb', line 8 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 46 47 48 |
# File 'lib/nis/request/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 serialized = serialize(entity_hash) hex_serialized = Nis::Util::Convert.ua2hex(serialized) { data: Nis::Util::Convert.ua2hex(serialized), signature: signature(hex_serialized) } end |