Module: SolidRail::Mapper
- Defined in:
- lib/solidrail/mapper.rb
Overview
Mapper module for converting Ruby types and syntax to Solidity
Class Method Summary collapse
- .map_function_type(ruby_method) ⇒ Object
- .map_type(ruby_type) ⇒ Object
- .map_visibility(ruby_visibility) ⇒ Object
Class Method Details
.map_function_type(ruby_method) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/solidrail/mapper.rb', line 25 def map_function_type(ruby_method) # Determine if function is pure, view, or payable if ruby_method.include?('pure') 'pure' elsif ruby_method.include?('view') 'view' elsif ruby_method.include?('payable') 'payable' else '' end end |
.map_type(ruby_type) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/solidrail/mapper.rb', line 7 def map_type(ruby_type) case ruby_type when Integer then 'uint256' when String then 'string' when Array then 'uint256[]' when Hash then 'mapping(address => uint256)' when Symbol then 'enum' end end |
.map_visibility(ruby_visibility) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/solidrail/mapper.rb', line 17 def map_visibility(ruby_visibility) { public: 'public', private: 'private', protected: 'internal' }.fetch(ruby_visibility, 'public') end |