Class: Micon::Core

Inherits:
Object show all
Defined in:
lib/rad/configurators/_require.rb,
lib/rad/environment/_require.rb,
lib/rad/_support/extensions.rb

Overview

Handy mehtods

Instance Method Summary collapse

Instance Method Details

#configure(configurator_name, dir, &block) ⇒ Object



8
9
10
11
12
# File 'lib/rad/configurators/_require.rb', line 8

def configure configurator_name, dir, &block
  configurator_class = "Rad::Configurators::#{configurator_name.to_s.classify}".constantize
  configurator = configurator_class.new dir
  block.call configurator if block
end

#development(&block) ⇒ Object



21
# File 'lib/rad/environment/_require.rb', line 21

def development █ block.call if development? end

#development?Boolean

Returns:

  • (Boolean)


17
# File 'lib/rad/environment/_require.rb', line 17

def development?; mode == :development end

#extension(name, target = nil, *args, &default_extension) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rad/_support/extensions.rb', line 11

def extension name, target = nil, *args, &default_extension
  name.must_be.a Symbol

  if block = extensions[name] || default_extension
    target ? target.instance_exec(*args, &block) : block.call(*args)
  end
end

#extensionsObject



19
# File 'lib/rad/_support/extensions.rb', line 19

def extensions; @extensions ||= {} end

#production(&block) ⇒ Object



22
# File 'lib/rad/environment/_require.rb', line 22

def production █ block.call if production? end

#production?Boolean

Returns:

  • (Boolean)


18
# File 'lib/rad/environment/_require.rb', line 18

def production?; mode == :production end

#register_extension(name, &block) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/rad/_support/extensions.rb', line 2

def register_extension name, &block
  name.must_be.a Symbol
  block.must_be.defined

  raise "extension :#{name} already registered!" if extensions.include? name

  extensions[name] = block
end

#test(&block) ⇒ Object



23
# File 'lib/rad/environment/_require.rb', line 23

def test █ block.call if test? end

#test?Boolean

Returns:

  • (Boolean)


19
# File 'lib/rad/environment/_require.rb', line 19

def test?; mode == :test end