Class: Hanami::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/configuration.rb

Defined Under Namespace

Classes: App

Instance Method Summary collapse

Constructor Details

#initialize(&blk) ⇒ Configuration

Returns a new instance of Configuration


18
19
20
21
# File 'lib/hanami/configuration.rb', line 18

def initialize(&blk)
  @settings = Concurrent::Map.new
  instance_eval(&blk)
end

Instance Method Details

#appsObject


43
44
45
46
47
# File 'lib/hanami/configuration.rb', line 43

def apps
  mounted.each_pair do |klass, app|
    yield(app) if klass.ancestors.include?(Hanami::Application)
  end
end

#mailer(&blk) ⇒ Object


35
36
37
# File 'lib/hanami/configuration.rb', line 35

def mailer(&blk)
  settings.put_if_absent(:mailer, blk)
end

#model(&blk) ⇒ Object


27
28
29
30
31
32
33
# File 'lib/hanami/configuration.rb', line 27

def model(&blk)
  if block_given?
    settings.put_if_absent(:model, blk)
  else
    settings.fetch(:model)
  end
end

#mount(app, options) ⇒ Object


23
24
25
# File 'lib/hanami/configuration.rb', line 23

def mount(app, options)
  mounted[app] = App.new(app, options.fetch(:at))
end

#mountedObject


39
40
41
# File 'lib/hanami/configuration.rb', line 39

def mounted
  settings.fetch_or_store(:mounted, {})
end