Class: RBS::Prototype::Runtime::ValueObjectBase
- Inherits:
-
Object
- Object
- RBS::Prototype::Runtime::ValueObjectBase
- Includes:
- Helpers
- Defined in:
- lib/rbs/prototype/runtime/value_object_generator.rb,
sig/prototype/runtime.rbs
Direct Known Subclasses
Instance Method Summary collapse
- #add_decl_members ⇒ void
- #build_decl ⇒ AST::Declarations::Class
-
#build_member_accessors(ast_members_class) ⇒ Object
attr_accessor foo: untyped.
-
#build_s_members ⇒ Array[AST::Members::MethodDefinition]
def self.members: () -> [ :foo, :bar ] def members: () -> [ :foo, :bar ].
- #build_super_class ⇒ AST::Declarations::Class::Super
-
#initialize(target_class) ⇒ ValueObjectBase
constructor
A new instance of ValueObjectBase.
Methods included from Helpers
#const_name, #const_name!, #only_name, #to_type_name, #untyped
Constructor Details
#initialize(target_class) ⇒ ValueObjectBase
Returns a new instance of ValueObjectBase.
11 12 13 |
# File 'lib/rbs/prototype/runtime/value_object_generator.rb', line 11 def initialize(target_class) @target_class = target_class end |
Instance Method Details
#add_decl_members ⇒ void
This method returns an undefined value.
46 |
# File 'sig/prototype/runtime.rbs', line 46
def add_decl_members: (AST::Declarations::Class) -> void
|
#build_decl ⇒ AST::Declarations::Class
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rbs/prototype/runtime/value_object_generator.rb', line 15 def build_decl decl = AST::Declarations::Class.new( name: to_type_name(only_name(@target_class)), type_params: [], super_class: build_super_class, members: [], annotations: [], location: nil, comment: nil ) add_decl_members(decl) decl end |
#build_member_accessors(ast_members_class) ⇒ Object
attr_accessor foo: untyped
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rbs/prototype/runtime/value_object_generator.rb', line 74 def build_member_accessors(ast_members_class) @target_class.members.map do |member| ast_members_class.new( name: member, ivar_name: nil, type: untyped, kind: :instance, location: nil, comment: nil, annotations: ( [] #: Array[AST::Annotation] ) ) end end |
#build_s_members ⇒ Array[AST::Members::MethodDefinition]
def self.members: () -> [ :foo, :bar ] def members: () -> [ :foo, :bar ]
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rbs/prototype/runtime/value_object_generator.rb', line 35 def build_s_members ( [:singleton, :instance] #: Array[AST::Members::MethodDefinition::kind] ).map do |kind| AST::Members::MethodDefinition.new( name: :members, overloads: [ AST::Members::MethodDefinition::Overload.new( annotations: [], method_type: MethodType.new( type: Types::Function.empty( Types::Tuple.new( types: @target_class.members.map do |member| if member.to_s.ascii_only? Types::Literal.new(literal: member, location: nil) else BuiltinNames::Symbol.instance_type end end, location: nil ) ), type_params: [], block: nil, location: nil, ) ) ], kind: kind, location: nil, comment: nil, annotations: [], overloading: false, visibility: nil ) end end |
#build_super_class ⇒ AST::Declarations::Class::Super
44 |
# File 'sig/prototype/runtime.rbs', line 44
def build_super_class: () -> AST::Declarations::Class::Super
|