Class: TonClient::Context
- Defined in:
- lib/ton-client-ruby/Client/Context.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
- #config=(value = {}) ⇒ Object
- #destroy ⇒ Object
-
#initialize(config: {}) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(config: {}) ⇒ Context
Returns a new instance of Context.
6 7 8 9 10 11 12 |
# File 'lib/ton-client-ruby/Client/Context.rb', line 6 def initialize(config: {}) TonClient.check_configuration @config = TonBinding.make_string(config.to_json) context = TonBinding.tc_create_context(@config) @id = TonBinding.read_string_to_hash(context)['result'] ObjectSpace.define_finalizer(self, self.class.finalize(@id)) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/ton-client-ruby/Client/Context.rb', line 4 def id @id end |
Class Method Details
.finalize(id) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/ton-client-ruby/Client/Context.rb', line 26 def self.finalize(id) Proc.new do if (id != nil) && (id > 0) TonBinding.tc_destroy_context(id) end end end |
Instance Method Details
#config ⇒ Object
18 19 20 |
# File 'lib/ton-client-ruby/Client/Context.rb', line 18 def config TonBinding.read_string_to_hash(@config) end |
#config=(value = {}) ⇒ Object
14 15 16 |
# File 'lib/ton-client-ruby/Client/Context.rb', line 14 def config=(value = {}) @config = TonBinding.make_string(value.to_json) end |
#destroy ⇒ Object
22 23 24 |
# File 'lib/ton-client-ruby/Client/Context.rb', line 22 def destroy TonBinding.tc_destroy_context(id) end |