Module: Mackarel::Core

Included in:
Mackarel
Defined in:
lib/mackarel/core.rb

Instance Method Summary collapse

Instance Method Details

#create_a(what, *args, called: what, **options) {|asset| ... } ⇒ Object Also known as: when_there_exists_a, when_there_exists_an, and_there_exists_a, and_there_exists_an

Yields:

  • (asset)


7
8
9
10
11
12
13
14
15
# File 'lib/mackarel/core.rb', line 7

def create_a(what, *args, called: what, **options)
  asset = factory.create(what, *args, **options)
  if called
    called = called.to_s.underscore.tr("/", "_")
    instance_variable_set("@#{called}", asset)
  end
  yield(asset) if block_given?
  asset
end

#create_a_list_of(number, what, *args, called: "#{what}_list", **options) {|asset| ... } ⇒ Object Also known as: and_there_exist, when_there_exist

Yields:

  • (asset)


17
18
19
20
21
22
23
24
25
# File 'lib/mackarel/core.rb', line 17

def create_a_list_of(number, what, *args, called: "#{what}_list", **options)
  asset = factory.create_list(what, number, *args, **options)
  if called
    called = called.underscore.tr("/", "_")
    instance_variable_set("@#{called}", asset)
  end
  yield(asset) if block_given?
  asset
end

#factoryObject



27
28
29
# File 'lib/mackarel/core.rb', line 27

def factory
  Mackarel.config.factory
end

#when_iObject Also known as: and_i, and_also, given, then_i



3
4
5
# File 'lib/mackarel/core.rb', line 3

def when_i
  yield
end