Class: Aws::Templates::Utils::Default::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/templates/utils/default.rb

Overview

Abstract defaults definition

Defaults definition is an object wrapper which enables definition merging. It also contains factory method to transform arbitrary objects into Definition object and defines basic functionality.

Direct Known Subclasses

Calculable, Empty, Pair, Scalar, Scheme

Defined Under Namespace

Classes: Calculable, Empty, Pair, Scalar, Scheme

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.emptyObject



194
195
196
# File 'lib/aws/templates/utils/default.rb', line 194

def empty
  Empty.instance
end

.from(obj) ⇒ Object



198
199
200
201
202
203
204
205
# File 'lib/aws/templates/utils/default.rb', line 198

def from(obj)
  return obj if obj.is_a? Definition
  return Scalar.new(obj) if obj.override?
  return Scheme.new(obj) if Utils.recursive?(obj)
  return Calculable.new(obj) if obj.respond_to?(:to_proc)

  raise "Invalid object #{obj}"
end

Instance Method Details

#for(_) ⇒ Object



214
215
216
# File 'lib/aws/templates/utils/default.rb', line 214

def for(_)
  raise 'Must be overriden'
end

#merge(b) ⇒ Object



208
209
210
211
212
# File 'lib/aws/templates/utils/default.rb', line 208

def merge(b)
  return b if b.override?
  return self if b == Definition.empty
  Pair[self, b]
end

#override?Boolean

Returns:

  • (Boolean)


222
223
224
# File 'lib/aws/templates/utils/default.rb', line 222

def override?
  false
end

#to_definitionObject



218
219
220
# File 'lib/aws/templates/utils/default.rb', line 218

def to_definition
  self
end