Class: Yarrow::Schema::Types::Interface

Inherits:
TypeClass
  • Object
show all
Defined in:
lib/yarrow/schema/types.rb

Instance Attribute Summary collapse

Attributes inherited from TypeClass

#accepts, #unit

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TypeClass

#accept, #cast, #check_instance_of!, #check_kind_of!, #check_respond_to_all!, #check_respond_to_any!, #coerce, #initialize, of, #should_coerce?

Constructor Details

This class inherits a constructor from Yarrow::Schema::Types::TypeClass

Instance Attribute Details

#implementationObject

Returns the value of attribute implementation.



111
112
113
# File 'lib/yarrow/schema/types.rb', line 111

def implementation
  @implementation
end

Class Method Details

.all(*args) ⇒ Object



105
106
107
108
109
# File 'lib/yarrow/schema/types.rb', line 105

def self.all(*args)
  interface_type = new(args)
  interface_type.implementation = :all
  interface_type
end

.any(*args) ⇒ Object



99
100
101
102
103
# File 'lib/yarrow/schema/types.rb', line 99

def self.any(*args)
  interface_type = new(args)
  interface_type.implementation = :any
  interface_type
end

Instance Method Details

#check(input) ⇒ Object



115
116
117
118
119
120
121
122
# File 'lib/yarrow/schema/types.rb', line 115

def check(input)
  case implementation
  when :any then check_respond_to_any!(input, members)
  when :all then check_respond_to_all!(input, members)
  end

  input
end