Class: RBS::Prototype::Runtime::ValueObjectBase
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Helpers
|
|
Inherits: | Object |
Defined in: | lib/rbs/prototype/runtime/value_object_generator.rb |
Class Method Summary
- .new(target_class) ⇒ ValueObjectBase constructor
Instance Method Summary
- #build_decl
-
#build_member_accessors(ast_members_class)
private
attr_accessor foo: untyped.
-
#build_s_members
private
def self.members: () -> [
:foo
,:bar
] def members: () -> [:foo
,:bar
].
Helpers
- Included
#const_name, #const_name!, | |
#only_name | Returns the exact name & not compactly declared name. |
#to_type_name, #untyped |
Constructor Details
.new(target_class) ⇒ ValueObjectBase
# File 'lib/rbs/prototype/runtime/value_object_generator.rb', line 11
def initialize(target_class) @target_class = target_class end
Instance Method Details
#build_decl
[ GitHub ]# 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) (private)
attr_accessor foo: untyped
# 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: [] ) end end
#build_s_members (private)
def self.members: () -> [ :foo
, :bar
] def members: () -> [ :foo
, :bar
]
# 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