class Simnos::DSL::SNS

Attributes

result[R]

Public Class Methods

new(context, topics, &block) click to toggle source
# File lib/simnos/dsl/sns.rb, line 11
def initialize(context, topics, &block)
  @context = context

  @result  = OpenStruct.new(
    topics: topics
  )
  @names = topics.map(&:name)
  instance_eval(&block)
end

Private Instance Methods

topic(name, &block) click to toggle source
# File lib/simnos/dsl/sns.rb, line 23
def topic(name, &block)
  if @names.include?(name)
    raise "#{name} is already defined"
  end

  @result.topics << Topic.new(@context, name, &block).result
  @names << name
end