Module: Waves::Layers::MVC

Defined in:
lib/waves/layers/mvc.rb

Class Method Summary collapse

Class Method Details

.included(app) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/waves/layers/mvc.rb', line 5

def self.included( app )
  
  require 'waves/layers/mvc/extensions'
  require 'waves/layers/mvc/controllers'
  require 'hoshi'
  require 'waves/helpers/basic'
  require 'waves/helpers/formatting'
  require 'waves/helpers/form'
  
  app.auto_create_module( :Models ) do
    auto_create_class :Default
    auto_load :Default, :directories => [ :models ]
    auto_create_class true, :Default
    auto_load true, :directories => [ :models ]
  end

  app.auto_create_module( :Views ) do
    auto_create_class :Default, Hoshi::View[:html4] do
      include Waves::Views::Mixin
      include Waves::Helpers::Basic
      include Waves::Helpers::Formatting
      include Waves::Helpers::Form
    end
    auto_create_class :Templated do
      include Waves::Views::Mixin
      include Waves::Views::Templated
    end
    auto_load :Default, :directories => [ :views ]
    auto_create_class true, :Default
    auto_load true, :directories => [ :views ]
  end

  app.auto_create_module( :Controllers ) do
    auto_create_class :Default, Waves::Controllers::Base
    auto_load :Default, :directories => [ :controllers ]
    auto_create_class true, :Default
    auto_load true, :directories => [ :controllers ]          
  end

  #
  # We autoload helpers and so forth to emulate Rails technique
  # of having an application-level helper (Default) and then one
  # per view class. However, we only use this with templated views
  # (since mixing in a helper module is sometimes a bit tricky).
  # "Native" Waves views (aka Hoshi) are ordinary classes so they
  # don't really need this, but you can always just include a class
  # level helper and it will automatically pick up your defaults
  # if it is not explicitly defined.
  #
  
  app.auto_create_module( :Helpers ) do
    auto_create_module( :Default )
    auto_load :Default, :directories => [ :helpers ]
    auto_create_module( true ) { include app::Helpers::Default }
    auto_load true, :directories => [ :helpers ]
  end
  
end