Class: Steep::Interface::Shape::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/interface/shape.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(overloads: nil, private_method:, method_name:, &block) ⇒ Entry

Returns a new instance of Entry.



63
64
65
66
67
68
# File 'lib/steep/interface/shape.rb', line 63

def initialize(overloads: nil, private_method:, method_name:, &block)
  @overloads = overloads
  @generator = block
  @private_method = private_method
  @method_name = method_name
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



61
62
63
# File 'lib/steep/interface/shape.rb', line 61

def method_name
  @method_name
end

Instance Method Details

#forceObject



70
71
72
73
74
75
# File 'lib/steep/interface/shape.rb', line 70

def force
  unless @overloads
    @overloads = @generator&.call
    @generator = nil
  end
end

#has_method_type?Boolean

Returns:

  • (Boolean)


86
87
88
89
# File 'lib/steep/interface/shape.rb', line 86

def has_method_type?
  force
  @overloads ? true : false
end

#method_typesObject



82
83
84
# File 'lib/steep/interface/shape.rb', line 82

def method_types
  overloads.map(&:method_type)
end

#overloadsObject



77
78
79
80
# File 'lib/steep/interface/shape.rb', line 77

def overloads
  force
  @overloads or raise
end

#private_method?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/steep/interface/shape.rb', line 99

def private_method?
  @private_method
end

#public_method?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/steep/interface/shape.rb', line 103

def public_method?
  !private_method?
end

#to_sObject



91
92
93
94
95
96
97
# File 'lib/steep/interface/shape.rb', line 91

def to_s
  if @generator
    "<< Lazy entry >>"
  else
    "{ #{method_types.join(" || ")} }"
  end
end