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.



55
56
57
58
59
60
# File 'lib/steep/interface/shape.rb', line 55

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.



53
54
55
# File 'lib/steep/interface/shape.rb', line 53

def method_name
  @method_name
end

Instance Method Details

#forceObject



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

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

#has_method_type?Boolean

Returns:

  • (Boolean)


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

def has_method_type?
  force
  @overloads ? true : false
end

#method_typesObject



74
75
76
# File 'lib/steep/interface/shape.rb', line 74

def method_types
  overloads.map(&:method_type)
end

#overloadsObject



69
70
71
72
# File 'lib/steep/interface/shape.rb', line 69

def overloads
  force
  @overloads or raise
end

#private_method?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/steep/interface/shape.rb', line 91

def private_method?
  @private_method
end

#public_method?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/steep/interface/shape.rb', line 95

def public_method?
  !private_method?
end

#to_sObject



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

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