Class: DuckTyper::InterfaceSetup
- Inherits:
-
Object
- Object
- DuckTyper::InterfaceSetup
- Defined in:
- lib/duck_typer/interface_setup.rb
Instance Attribute Summary collapse
-
#checker ⇒ Object
readonly
Returns the value of attribute checker.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#objects ⇒ Object
readonly
Returns the value of attribute objects.
-
#strict ⇒ Object
readonly
Returns the value of attribute strict.
Instance Method Summary collapse
-
#initialize(objects, namespace:, type:, methods:, strict:, name:, minimum: 0) ⇒ InterfaceSetup
constructor
A new instance of InterfaceSetup.
Constructor Details
#initialize(objects, namespace:, type:, methods:, strict:, name:, minimum: 0) ⇒ InterfaceSetup
Returns a new instance of InterfaceSetup.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/duck_typer/interface_setup.rb', line 9 def initialize(objects, namespace:, type:, methods:, strict:, name:, minimum: 0) raise ArgumentError, "cannot specify both objects and namespace" if objects && namespace raise ArgumentError, "objects or namespace is required" if objects.nil? && namespace.nil? @objects = resolve_objects(objects, namespace) raise ArgumentError, "at least #{minimum} object(s) required" if @objects.size < minimum name ||= namespace&.name @name = name @strict = strict @checker = InterfaceChecker.new(type:, methods:, strict:, name:) end |
Instance Attribute Details
#checker ⇒ Object (readonly)
Returns the value of attribute checker.
7 8 9 |
# File 'lib/duck_typer/interface_setup.rb', line 7 def checker @checker end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/duck_typer/interface_setup.rb', line 7 def name @name end |
#objects ⇒ Object (readonly)
Returns the value of attribute objects.
7 8 9 |
# File 'lib/duck_typer/interface_setup.rb', line 7 def objects @objects end |
#strict ⇒ Object (readonly)
Returns the value of attribute strict.
7 8 9 |
# File 'lib/duck_typer/interface_setup.rb', line 7 def strict @strict end |