class ApiBlueprint::Collection

Attributes

blueprints[R]
creates[R]

Public Class Methods

new(blueprints, creates = nil) click to toggle source
# File lib/api-blueprint/collection.rb, line 6
def initialize(blueprints, creates = nil)
  unless blueprints.is_a?(Hash)
    raise DefinitionError, "a collection of blueprints must be a hash"
  end

  unless blueprints.values.all? { |bp| bp.is_a? Blueprint }
    raise DefinitionError, "all collection values must be blueprints"
  end

  @blueprints = blueprints
  @creates = creates
end

Public Instance Methods

create(args) click to toggle source
# File lib/api-blueprint/collection.rb, line 19
def create(args)
  creates.present? ? creates.new(args) : args
end