Module: Mackarel::Core
- Included in:
- Mackarel
- Defined in:
- lib/mackarel/core.rb
Instance Method Summary collapse
- #create_a(what, *args, called: what, **options) {|asset| ... } ⇒ Object (also: #when_there_exists_a, #when_there_exists_an, #and_there_exists_a, #and_there_exists_an)
- #create_a_list_of(number, what, *args, called: "#{what}_list", **options) {|asset| ... } ⇒ Object (also: #and_there_exist, #when_there_exist)
- #factory ⇒ Object
- #when_i ⇒ Object (also: #and_i, #and_also, #given, #then_i)
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
7 8 9 10 11 12 13 14 15 |
# File 'lib/mackarel/core.rb', line 7 def create_a(what, *args, called: what, **) asset = factory.create(what, *args, **) 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
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", **) asset = factory.create_list(what, number, *args, **) if called called = called.underscore.tr("/", "_") instance_variable_set("@#{called}", asset) end yield(asset) if block_given? asset end |
#factory ⇒ Object
27 28 29 |
# File 'lib/mackarel/core.rb', line 27 def factory Mackarel.config.factory end |
#when_i ⇒ Object 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 |