Module: Taro::CommonReturns

Defined in:
lib/taro/common_returns.rb

Overview

Holds common return definitions for a set of declarations, e.g. shared error responses, within a class and its subclasses.

Defined Under Namespace

Modules: InheritedCallback

Class Method Summary collapse

Class Method Details

.define(klass, nesting = nil) ⇒ Object



5
6
7
8
# File 'lib/taro/common_returns.rb', line 5

def define(klass, nesting = nil, **)
  (map[klass] ||= []) << Taro::ReturnDef.new(nesting:, **)
  klass.extend(InheritedCallback)
end

.for(klass) ⇒ Object



14
15
16
# File 'lib/taro/common_returns.rb', line 14

def for(klass)
  map[klass] || []
end

.inherit(from_class, to_class) ⇒ Object



10
11
12
# File 'lib/taro/common_returns.rb', line 10

def inherit(from_class, to_class)
  map[to_class] = map[from_class].dup
end