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.



130
131
132
# File 'lib/yarrow/schema/types.rb', line 130

def implementation
  @implementation
end

Class Method Details

.all(*args) ⇒ Object



124
125
126
127
128
# File 'lib/yarrow/schema/types.rb', line 124

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

.any(*args) ⇒ Object



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

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

Instance Method Details

#check(input) ⇒ Object



134
135
136
137
138
139
140
141
# File 'lib/yarrow/schema/types.rb', line 134

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