Module: Swagger::Bash

Defined in:
lib/swagger/builder.rb

Overview

A Bash is a ‘builder’ Hash that can be used to be a Dash (‘defined’ or ‘discrete’ Hash). It provides a build method that turns it into a Dash. It enforces the same rules as a Dash except for ‘required’ properties, which are not enforced until converting to a Dash via ‘build`.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#[](key, &_block) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/swagger/builder.rb', line 41

def [](key, &_block)
  super(key) do |v|
    if block_given?
      v ||= send(:[]=, key, {})
      yield v
      v
    end
  end
end

#buildObject



52
53
54
# File 'lib/swagger/builder.rb', line 52

def build
  self.class.superclass.new(to_hash)
end