Class: Webhookdb::TypedStruct
- Inherits:
-
Object
- Object
- Webhookdb::TypedStruct
show all
- Defined in:
- lib/webhookdb/typed_struct.rb
Direct Known Subclasses
DBAdapter::Column, DBAdapter::Index, DBAdapter::Schema, DBAdapter::Table, DBAdapter::TableDescriptor, Increase::WebhookSignature, Oauth::Tokens, Replicator::Base::CredentialVerificationResult, Replicator::Column::IsomorphicProc, Replicator::Descriptor, Replicator::IndexSpec, Replicator::WebhookRequest, WebhookResponse
Instance Method Summary
collapse
Constructor Details
#initialize(**kwargs) ⇒ TypedStruct
Returns a new instance of TypedStruct.
4
5
6
|
# File 'lib/webhookdb/typed_struct.rb', line 4
def initialize(**kwargs)
self._apply(self._defaults.merge(kwargs))
end
|
Instance Method Details
#[](k) ⇒ Object
12
13
14
|
# File 'lib/webhookdb/typed_struct.rb', line 12
def [](k)
return self.send(k)
end
|
#_apply(kwargs) ⇒ Object
Modify the receiver with kwargs.
17
18
19
20
21
22
|
# File 'lib/webhookdb/typed_struct.rb', line 17
def _apply(kwargs)
kwargs.each do |k, v|
raise TypeError, "invalid struct field #{k}" unless self.respond_to?(k)
self.instance_variable_set(:"@#{k}", v)
end
end
|
#_defaults ⇒ Object
8
9
10
|
# File 'lib/webhookdb/typed_struct.rb', line 8
def _defaults
return {}
end
|
#as_json ⇒ Object
30
31
32
|
# File 'lib/webhookdb/typed_struct.rb', line 30
def as_json
return self.instance_values.as_json
end
|
#change ⇒ Object
24
25
26
27
28
|
# File 'lib/webhookdb/typed_struct.rb', line 24
def change(**)
c = self.dup
c._apply(**)
return c
end
|