Module: Scale::Types::Base
- Included in:
- Array, Bool, BoxProposal, Bytes, Compact, CompactMoment, EcdsaSignature, Enum, Era, EthereumAddress, EventRecord, EventRecords, Extrinsic, FixedWidthInt, FixedWidthUInt, GenericAddress, GenericBlock, H160, H256, H512, Hex, Metadata, MetadataModule, MetadataModuleCall, MetadataModuleCallArgument, MetadataModuleError, MetadataModuleEvent, MetadataModuleStorage, MetadataV0, MetadataV0Event, MetadataV0EventModule, MetadataV0Module, MetadataV0ModuleCallArgument, MetadataV0ModuleFunction, MetadataV0ModuleStorage, MetadataV0Section, MetadataV1, MetadataV10, MetadataV11, MetadataV12, MetadataV12Module, MetadataV13, MetadataV13Module, MetadataV13ModuleStorage, MetadataV13ModuleStorageEntry, MetadataV1Module, MetadataV1ModuleStorage, MetadataV2, MetadataV3, MetadataV4, MetadataV4Module, MetadataV4ModuleStorage, MetadataV5, MetadataV5Module, MetadataV5ModuleStorage, MetadataV6, MetadataV6Module, MetadataV6ModuleConstants, MetadataV7, MetadataV7Module, MetadataV7ModuleConstants, MetadataV7ModuleStorage, MetadataV7ModuleStorageEntry, MetadataV8, MetadataV8Module, MetadataV9, Null, Option, OptionBool, Set, String, Struct, TrieNode, Tuple, Vec, VecH512Length2, VecU8FixedLength, VoteOutcome
- Defined in:
- lib/scale/base.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/scale/base.rb', line 5 def value @value end |
Class Method Details
.included(base) ⇒ Object
45 46 47 48 |
# File 'lib/scale/base.rb', line 45 def self.included(base) base.extend(ClassMethods) base.const_set(:TYPE_NAME, base.name) end |
Instance Method Details
#==(other) ⇒ Object
11 12 13 |
# File 'lib/scale/base.rb', line 11 def ==(other) self.class == other.class && self.value == other.value end |
#initialize(value) ⇒ Object
7 8 9 |
# File 'lib/scale/base.rb', line 7 def initialize(value) @value = value end |
#to_human ⇒ Object
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/scale/base.rb', line 15 def to_human if @value.class == ::Hash @value.transform_values do |v| if v.class.included_modules.include?(Base) v.to_human else v end end.transform_keys(&:to_sym) elsif @value.class == ::Array @value.map do |v| if v.class.included_modules.include?(Base) v.to_human else v end end elsif @value.class.include?(Base) @value.to_human else @value end end |