Class: Monark::DSL

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/monark/dsl.rb

Overview

The Monark DSL.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context = nil) ⇒ DSL

Returns a new instance of DSL.



9
10
11
# File 'lib/monark/dsl.rb', line 9

def initialize(context = nil)
  @_context = context
end

Instance Attribute Details

#_contextObject (readonly)

Returns the value of attribute _context.



7
8
9
# File 'lib/monark/dsl.rb', line 7

def _context
  @_context
end

Instance Method Details

#add(name, options = {}, &block) ⇒ Object



23
24
25
26
27
# File 'lib/monark/dsl.rb', line 23

def add(name, options = {}, &block)
  groups(options.fetch(:group, options[:groups])) do
    _context.push Migration.new(_context.root, name, block)
  end
end

#groups(*args, &block) ⇒ Object Also known as: group



13
14
15
16
# File 'lib/monark/dsl.rb', line 13

def groups(*args, &block)
  groups = args.flatten.compact
  yield if groups.empty? || groups.include?(_context.env.to_sym)
end

#load(name, options = {}, &block) ⇒ Object



29
30
31
32
# File 'lib/monark/dsl.rb', line 29

def load(name, options = {}, &block)
  add(name, options, &block)
  _context.migrations.last.reloadable = true
end

#set_version(arg) ⇒ Object



19
20
21
# File 'lib/monark/dsl.rb', line 19

def set_version(arg)
  _context.version = arg
end