Class: Coconut::Dsl::Application

Inherits:
BlankSlate show all
Defined in:
lib/coconut/dsl/application.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BlankSlate

__forbidden_names

Constructor Details

#initialize(current_environment) ⇒ Application

Returns a new instance of Application.



12
13
14
# File 'lib/coconut/dsl/application.rb', line 12

def initialize(current_environment)
  @current_environment = current_environment
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(asset, *args, &config) ⇒ Object (private)



36
37
38
39
# File 'lib/coconut/dsl/application.rb', line 36

def method_missing(asset, *args, &config)
  ::Kernel::raise InvalidName, "#{asset} can't be used as asset name" if _taken?(asset)
  @assets_config[asset] = Asset.configure(@current_environment, &config)
end

Class Method Details

.configure(current_environment, &config) ⇒ Object



8
9
10
# File 'lib/coconut/dsl/application.rb', line 8

def self.configure(current_environment, &config)
  new(current_environment).run(&config)
end

Instance Method Details

#run(&config) ⇒ Object



16
17
18
19
20
# File 'lib/coconut/dsl/application.rb', line 16

def run(&config)
  @assets_config = {}
  instance_eval &config
  Config.with(@assets_config)
end