waves-stable 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. data/app/Rakefile +72 -0
  2. data/app/bin/waves-console +4 -0
  3. data/app/bin/waves-server +4 -0
  4. data/app/configurations/development.rb.erb +31 -0
  5. data/app/configurations/mapping.rb.erb +14 -0
  6. data/app/configurations/production.rb.erb +31 -0
  7. data/app/controllers/.gitignore +0 -0
  8. data/app/doc/.gitignore +0 -0
  9. data/app/helpers/.gitignore +0 -0
  10. data/app/lib/application.rb.erb +5 -0
  11. data/app/lib/tasks/.gitignore +0 -0
  12. data/app/log/.gitignore +0 -0
  13. data/app/models/.gitignore +0 -0
  14. data/app/public/css/.gitignore +0 -0
  15. data/app/public/flash/.gitignore +0 -0
  16. data/app/public/images/.gitignore +0 -0
  17. data/app/public/javascript/.gitignore +0 -0
  18. data/app/schema/migrations/.gitignore +0 -0
  19. data/app/startup.rb +5 -0
  20. data/app/templates/errors/not_found_404.mab +2 -0
  21. data/app/templates/errors/server_error_500.mab +2 -0
  22. data/app/templates/layouts/default.mab +14 -0
  23. data/app/tmp/sessions/.gitignore +0 -0
  24. data/app/views/.gitignore +0 -0
  25. data/bin/waves +84 -0
  26. data/bin/waves-console +4 -0
  27. data/bin/waves-server +4 -0
  28. data/doc/HISTORY +44 -0
  29. data/doc/LICENSE +22 -0
  30. data/lib/commands/waves-console.rb +21 -0
  31. data/lib/commands/waves-server.rb +55 -0
  32. data/lib/controllers/base.rb +11 -0
  33. data/lib/controllers/mixin.rb +165 -0
  34. data/lib/dispatchers/base.rb +67 -0
  35. data/lib/dispatchers/default.rb +81 -0
  36. data/lib/foundations/default.rb +27 -0
  37. data/lib/foundations/simple.rb +30 -0
  38. data/lib/helpers/asset_helper.rb +67 -0
  39. data/lib/helpers/common.rb +66 -0
  40. data/lib/helpers/default.rb +13 -0
  41. data/lib/helpers/form.rb +40 -0
  42. data/lib/helpers/formatting.rb +30 -0
  43. data/lib/helpers/model.rb +33 -0
  44. data/lib/helpers/number_helper.rb +25 -0
  45. data/lib/helpers/tag_helper.rb +58 -0
  46. data/lib/helpers/url_helper.rb +77 -0
  47. data/lib/helpers/view.rb +24 -0
  48. data/lib/layers/default_errors.rb +26 -0
  49. data/lib/layers/inflect/english.rb +24 -0
  50. data/lib/layers/inflect/english/rules.rb +88 -0
  51. data/lib/layers/inflect/english/string.rb +24 -0
  52. data/lib/layers/mvc.rb +54 -0
  53. data/lib/layers/orm/active_record.rb +92 -0
  54. data/lib/layers/orm/active_record/migrations/empty.rb.erb +9 -0
  55. data/lib/layers/orm/active_record/tasks/generate.rb +28 -0
  56. data/lib/layers/orm/active_record/tasks/schema.rb +22 -0
  57. data/lib/layers/orm/data_mapper.rb +38 -0
  58. data/lib/layers/orm/filebase.rb +22 -0
  59. data/lib/layers/orm/migration.rb +79 -0
  60. data/lib/layers/orm/sequel.rb +86 -0
  61. data/lib/layers/orm/sequel/migrations/empty.rb.erb +9 -0
  62. data/lib/layers/orm/sequel/tasks/generate.rb +28 -0
  63. data/lib/layers/orm/sequel/tasks/schema.rb +16 -0
  64. data/lib/layers/simple.rb +32 -0
  65. data/lib/layers/simple_errors.rb +23 -0
  66. data/lib/mapping/mapping.rb +289 -0
  67. data/lib/mapping/pretty_urls.rb +96 -0
  68. data/lib/renderers/erubis.rb +63 -0
  69. data/lib/renderers/haml.rb +45 -0
  70. data/lib/renderers/markaby.rb +33 -0
  71. data/lib/renderers/mixin.rb +50 -0
  72. data/lib/runtime/application.rb +69 -0
  73. data/lib/runtime/blackboard.rb +57 -0
  74. data/lib/runtime/configuration.rb +185 -0
  75. data/lib/runtime/console.rb +20 -0
  76. data/lib/runtime/debugger.rb +9 -0
  77. data/lib/runtime/logger.rb +59 -0
  78. data/lib/runtime/mime_types.rb +22 -0
  79. data/lib/runtime/request.rb +78 -0
  80. data/lib/runtime/response.rb +40 -0
  81. data/lib/runtime/response_mixin.rb +38 -0
  82. data/lib/runtime/response_proxy.rb +30 -0
  83. data/lib/runtime/server.rb +107 -0
  84. data/lib/runtime/session.rb +66 -0
  85. data/lib/tasks/cluster.rb +26 -0
  86. data/lib/tasks/gem.rb +31 -0
  87. data/lib/tasks/generate.rb +80 -0
  88. data/lib/utilities/hash.rb +31 -0
  89. data/lib/utilities/inflect.rb +110 -0
  90. data/lib/utilities/integer.rb +24 -0
  91. data/lib/utilities/module.rb +21 -0
  92. data/lib/utilities/object.rb +25 -0
  93. data/lib/utilities/proc.rb +16 -0
  94. data/lib/utilities/string.rb +49 -0
  95. data/lib/utilities/symbol.rb +10 -0
  96. data/lib/utilities/tempfile.rb +9 -0
  97. data/lib/views/base.rb +9 -0
  98. data/lib/views/mixin.rb +110 -0
  99. data/lib/waves.rb +84 -0
  100. data/samples/blog/Rakefile +14 -0
  101. data/samples/blog/bin/waves-console +3 -0
  102. data/samples/blog/bin/waves-server +3 -0
  103. data/samples/blog/configurations/development.rb +31 -0
  104. data/samples/blog/configurations/mapping.rb +23 -0
  105. data/samples/blog/configurations/production.rb +30 -0
  106. data/samples/blog/doc/EMTPY +0 -0
  107. data/samples/blog/lib/application.rb +5 -0
  108. data/samples/blog/models/comment.rb +14 -0
  109. data/samples/blog/models/entry.rb +14 -0
  110. data/samples/blog/public/css/site.css +2 -0
  111. data/samples/blog/public/javascript/site.js +13 -0
  112. data/samples/blog/schema/migrations/001_initial_schema.rb +17 -0
  113. data/samples/blog/schema/migrations/002_add_comments.rb +18 -0
  114. data/samples/blog/schema/migrations/templates/empty.rb.erb +9 -0
  115. data/samples/blog/startup.rb +6 -0
  116. data/samples/blog/templates/comment/add.mab +10 -0
  117. data/samples/blog/templates/comment/list.mab +6 -0
  118. data/samples/blog/templates/entry/editor.mab +13 -0
  119. data/samples/blog/templates/entry/list.mab +11 -0
  120. data/samples/blog/templates/entry/show.mab +9 -0
  121. data/samples/blog/templates/entry/summary.mab +5 -0
  122. data/samples/blog/templates/errors/not_found_404.mab +2 -0
  123. data/samples/blog/templates/errors/server_error_500.mab +2 -0
  124. data/samples/blog/templates/layouts/default.mab +17 -0
  125. data/verify/app_generation/helpers.rb +24 -0
  126. data/verify/app_generation/startup.rb +39 -0
  127. data/verify/blackboard/blackboard_verify.rb +92 -0
  128. data/verify/blackboard/helpers.rb +5 -0
  129. data/verify/configurations/attributes.rb +37 -0
  130. data/verify/configurations/helpers.rb +1 -0
  131. data/verify/configurations/rack_integration.rb +29 -0
  132. data/verify/controllers/base.rb +37 -0
  133. data/verify/controllers/helpers.rb +13 -0
  134. data/verify/controllers/interface.rb +51 -0
  135. data/verify/core/helpers.rb +3 -0
  136. data/verify/core/utilities.rb +177 -0
  137. data/verify/foundations/default.rb +86 -0
  138. data/verify/foundations/default_application/Rakefile +14 -0
  139. data/verify/foundations/default_application/bin/waves-console +3 -0
  140. data/verify/foundations/default_application/bin/waves-server +3 -0
  141. data/verify/foundations/default_application/configurations/development.rb +26 -0
  142. data/verify/foundations/default_application/configurations/mapping.rb +14 -0
  143. data/verify/foundations/default_application/configurations/production.rb +30 -0
  144. data/verify/foundations/default_application/controllers/default.rb +15 -0
  145. data/verify/foundations/default_application/controllers/loaded.rb +15 -0
  146. data/verify/foundations/default_application/defaultapplication.db +0 -0
  147. data/verify/foundations/default_application/helpers/loaded.rb +10 -0
  148. data/verify/foundations/default_application/lib/application.rb +5 -0
  149. data/verify/foundations/default_application/models/default.rb +13 -0
  150. data/verify/foundations/default_application/models/loaded.rb +13 -0
  151. data/verify/foundations/default_application/schema/migrations/templates/empty.rb.erb +9 -0
  152. data/verify/foundations/default_application/startup.rb +7 -0
  153. data/verify/foundations/default_application/templates/errors/not_found_404.mab +2 -0
  154. data/verify/foundations/default_application/templates/errors/server_error_500.mab +2 -0
  155. data/verify/foundations/default_application/templates/layouts/default.mab +14 -0
  156. data/verify/foundations/default_application/views/default.rb +7 -0
  157. data/verify/foundations/default_application/views/loaded.rb +15 -0
  158. data/verify/foundations/helpers.rb +1 -0
  159. data/verify/foundations/simple.rb +25 -0
  160. data/verify/helpers.rb +76 -0
  161. data/verify/layers/data_mapper/association_verify.rb +87 -0
  162. data/verify/layers/default_errors.rb +29 -0
  163. data/verify/layers/helpers.rb +1 -0
  164. data/verify/layers/migration.rb +33 -0
  165. data/verify/layers/sequel/model.rb +41 -0
  166. data/verify/mapping/always.rb +19 -0
  167. data/verify/mapping/filters.rb +65 -0
  168. data/verify/mapping/handle.rb +24 -0
  169. data/verify/mapping/helpers.rb +7 -0
  170. data/verify/mapping/matches.rb +27 -0
  171. data/verify/mapping/named.rb +29 -0
  172. data/verify/mapping/options.rb +17 -0
  173. data/verify/mapping/path.rb +40 -0
  174. data/verify/mapping/response_proxy.rb +50 -0
  175. data/verify/mapping/threaded.rb +25 -0
  176. data/verify/requests/helpers.rb +16 -0
  177. data/verify/requests/request.rb +73 -0
  178. data/verify/requests/response.rb +59 -0
  179. data/verify/requests/session.rb +54 -0
  180. data/verify/views/helpers.rb +1 -0
  181. data/verify/views/rendering.rb +34 -0
  182. data/verify/views/templates/foo.erb +0 -0
  183. data/verify/views/templates/moo.erb +0 -0
  184. data/verify/views/templates/moo.mab +0 -0
  185. metadata +439 -0
@@ -0,0 +1,24 @@
1
+ module Waves
2
+ module Layers
3
+ module Inflect
4
+ module English
5
+ module StringMethods
6
+
7
+ def singular
8
+ English::Rules.singular(self)
9
+ end
10
+
11
+ alias_method(:singularize, :singular)
12
+
13
+ def plural
14
+ English::Rules.plural(self)
15
+ end
16
+
17
+ alias_method(:pluralize, :plural)
18
+
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
data/lib/layers/mvc.rb ADDED
@@ -0,0 +1,54 @@
1
+ module Waves
2
+ module Layers
3
+ # The MVC layer establishes the Models, Views, Controllers, and Helpers namespaces inside
4
+ # a Waves application. In each namespace, undefined constants are handled by AutoCode, which
5
+ # loads the constant from the correct file in the appropriate directory if it exists, or creates
6
+ # from default otherwise.
7
+ module MVC
8
+
9
+ def self.included( app )
10
+
11
+ def app.models ; self::Models ; end
12
+ def app.views ; self::Views ; end
13
+ def app.controllers ; self::Controllers ; end
14
+ def app.helpers ; self::Helpers ; end
15
+
16
+ app.auto_create_module( :Models ) do
17
+ include AutoCode
18
+ auto_create_class :Default
19
+ auto_load :Default, :directories => [:models]
20
+ end
21
+
22
+ app.auto_eval( :Models ) do
23
+ auto_create_class true, app::Models::Default
24
+ auto_load true, :directories => [ :models ]
25
+ end
26
+
27
+ app.auto_create_module( :Views ) { include AutoCode }
28
+
29
+ app.auto_eval( :Views ) do
30
+ auto_create_class :Default, Waves::Views::Base
31
+ auto_load :Default, :directories => [:views]
32
+ auto_create_class true, app::Views::Default
33
+ auto_load true, :directories => [ :views ]
34
+ end
35
+
36
+ app.auto_create_module( :Controllers ) { include AutoCode }
37
+
38
+ app.auto_eval( :Controllers ) do
39
+ auto_create_class :Default, Waves::Controllers::Base
40
+ auto_load :Default, :directories => [:controllers]
41
+ auto_create_class true, app::Controllers::Default
42
+ auto_load true, :directories => [ :controllers ]
43
+ end
44
+
45
+ app.auto_create_module( :Helpers ) do
46
+ include AutoCode
47
+ auto_create_module { include Waves::Helpers::Default }
48
+ auto_load true, :directories => [ :helpers ]
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,92 @@
1
+ module Waves
2
+ module Layers
3
+ module ORM
4
+
5
+ # Sets up the ActiveRecord connection and configures AutoCode on Models, so that constants in that
6
+ # namespace get loaded from file or created as subclasses of Models::Default
7
+ module ActiveRecord
8
+
9
+ # On inclusion, this module:
10
+ # - creates on the application module a database method that establishes and returns the ActiveRecord connection
11
+ # - arranges for autoloading/autocreation of missing constants in the Models namespace
12
+ # - defines ActiveRecord-specific helper methods on Waves::Controllers::Base
13
+ #
14
+ # The controller helper methdods are:
15
+ # - all
16
+ # - find(name)
17
+ # - create
18
+ # - delete(name)
19
+ # - update(name)
20
+
21
+ def self.included(app)
22
+
23
+ class Symbol
24
+ # Protect ActiveRecord from itself by undefining the to_proc method.
25
+ # Don't worry, AR will redefine it.
26
+ alias :extensions_to_proc :to_proc
27
+ remove_method :to_proc
28
+ end
29
+ require 'active_record'
30
+ require "#{File.dirname(__FILE__)}/active_record/tasks/schema" if defined?(Rake)
31
+ require "#{File.dirname(__FILE__)}/active_record/tasks/generate" if defined?(Rake)
32
+
33
+ def app.database
34
+ unless @database
35
+ ::ActiveRecord::Base.establish_connection(config.database)
36
+ @database = ::ActiveRecord::Base.connection
37
+ end
38
+ @database
39
+ end
40
+
41
+ app.auto_create_module( :Models ) do
42
+ include AutoCode
43
+ auto_create_class :Default, ::ActiveRecord::Base
44
+ auto_load :Default, :directories => [ :models ]
45
+ end
46
+
47
+ app.auto_eval :Models do
48
+ auto_create_class true, app::Models::Default
49
+ auto_load true, :directories => [ :models ]
50
+
51
+ auto_eval true do
52
+ app.database
53
+ set_table_name basename.snake_case.pluralize.intern
54
+ end
55
+ end
56
+
57
+ Waves::Controllers::Base.instance_eval do
58
+ include Waves::Layers::ORM::ActiveRecord::ControllerMethods
59
+ end
60
+
61
+ end
62
+
63
+ # Mixed into Waves::Controllers::Base. Provides ORM-specific helper methods for model access.
64
+ module ControllerMethods
65
+ def all
66
+ model.find(:all)
67
+ end
68
+
69
+ def find( id )
70
+ model.find(id) or not_found
71
+ end
72
+
73
+ def create
74
+ model.create( attributes )
75
+ end
76
+
77
+ def delete( id )
78
+ find( id ).destroy
79
+ end
80
+
81
+ def update( id )
82
+ instance = find( id )
83
+ instance.update_attributes( attributes )
84
+ instance
85
+ end
86
+ end
87
+
88
+ end
89
+ end
90
+ end
91
+ end
92
+
@@ -0,0 +1,9 @@
1
+ class <%= @class_name %> < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ end
5
+
6
+ def self.down
7
+ end
8
+
9
+ end
@@ -0,0 +1,28 @@
1
+ namespace :generate do
2
+
3
+ desc 'Generate an ActiveRecord model, with name=<name>'
4
+ task :model do |task|
5
+ name = ENV['name']
6
+ model_name = name.camel_case
7
+ raise "Cannot generate Default yet" if model_name == 'Default'
8
+
9
+ filename = File.expand_path "models/#{name}.rb"
10
+ if File.exist?(filename)
11
+ $stderr.puts "#{filename} already exists"
12
+ exit
13
+ end
14
+
15
+ model = <<TEXT
16
+ module #{Waves.application.name}
17
+ module Models
18
+ class #{model_name} < Default
19
+
20
+ end
21
+ end
22
+ end
23
+ TEXT
24
+
25
+ File.write( filename, model )
26
+ end
27
+
28
+ end
@@ -0,0 +1,22 @@
1
+ require "#{File.dirname(__FILE__)}/../../migration"
2
+
3
+ namespace :schema do
4
+
5
+ desc "Create ActiveRecord migration with name=<name>"
6
+ task :migration do |task|
7
+ Waves::Layers::ORM.create_migration_for(ActiveRecord)
8
+ end
9
+
10
+ desc "Performs ActiveRecord migrations to version=<version>"
11
+ task :migrate => :connect do |task|
12
+ version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
13
+ ActiveRecord::Migrator.migrate(Waves::Layers::ORM.migration_directory, version)
14
+ end
15
+
16
+ task :connect do
17
+ Waves.application.database
18
+ ActiveRecord::Base.logger = Logger.new($stdout)
19
+ end
20
+
21
+ end
22
+
@@ -0,0 +1,38 @@
1
+ gem 'dm-core', '=0.9.0'
2
+
3
+ require 'data_mapper'
4
+
5
+ module Waves
6
+ module Layers
7
+ module ORM
8
+
9
+ # Work in Progress
10
+ module DataMapper
11
+
12
+ def self.included(app)
13
+
14
+ def app.database
15
+ @adapter ||= ::DataMapper.setup(:main_repository, config.database[:database])
16
+ end
17
+
18
+ app.auto_eval :Models do
19
+ auto_load true, :directories => [:models]
20
+ end
21
+
22
+ app.auto_eval :Configurations do
23
+ auto_eval :Mapping do
24
+ before true do
25
+ app.database #force adapter init if not already done
26
+ ::DataMapper::Repository.context.push(::DataMapper::Repository.new(:main_repository))
27
+ end
28
+ always true do
29
+ ::DataMapper::Repository.context.pop
30
+ end
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,22 @@
1
+ module Waves
2
+ module Layers
3
+ module ORM
4
+
5
+ # Work in Progress
6
+ module Filebase
7
+
8
+ def self.included(app)
9
+ app.module_eval do
10
+ auto_eval( :Models ) do
11
+ auto_eval( true ) { include Filebase::Model[ :db / self.name.snake_case ] }
12
+ end
13
+ end
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,79 @@
1
+ module Waves
2
+ module Layers
3
+
4
+ # Helper methods to establish inter-ORM standards
5
+ module ORM
6
+
7
+ # Glob pattern
8
+ MIGRATION_FILE_PATTERN = '[0-9][0-9][0-9]_*.rb'.freeze
9
+
10
+ def self.create_migration_for(orm)
11
+ source = migration_template(orm.to_s.snake_case, ENV['template'])
12
+ destination = migration_destination(ENV['name'])
13
+ migration_name = migration_name(ENV['name'])
14
+
15
+ context = {:class_name => migration_name.camel_case}
16
+
17
+ write_migration(context, source, destination)
18
+ end
19
+
20
+ # Where Waves keeps its migration files
21
+ def self.migration_directory
22
+ :schema / :migrations
23
+ end
24
+
25
+ # Returns any found migration files in the supplied directory.
26
+ def self.migration_files(range = nil)
27
+ pattern = migration_directory / MIGRATION_FILE_PATTERN
28
+ files = Dir[pattern].inject([]) do |m, path|
29
+ m[File.basename(path).to_i] = path
30
+ m
31
+ end
32
+ filtered = range ? files[range] : files
33
+ filtered ? filtered.compact : []
34
+ end
35
+
36
+ # Use the supplied version number or determine the next in sequence
37
+ # based on the migration files in the migration directory
38
+ def self.next_migration_version
39
+ version = ENV['version'] || latest_migration_version
40
+ version.to_i + 1
41
+ end
42
+
43
+ # Uses the migration files in the migration directory to determine
44
+ # the highest numbered existing migration.
45
+ def self.latest_migration_version
46
+ l = migration_files.last
47
+ l ? File.basename(l).to_i : nil
48
+ end
49
+
50
+ # If the user doesn't pass a name, defaults to "migration"
51
+ def self.migration_name(name=nil)
52
+ name || 'migration'
53
+ end
54
+
55
+ # Returns the path to the migration template file for the given ORM.
56
+ # <em>orm</em> can be a symbol or string
57
+ def self.migration_template(orm, name=nil)
58
+ file = ( name || 'empty' ) + '.rb.erb'
59
+ source = File.dirname(__FILE__) / orm / :migrations / file
60
+ end
61
+
62
+ # Given a migration name, returns the path of the file that would be created.
63
+ def self.migration_destination(name)
64
+ version = next_migration_version
65
+ migration_directory / "#{'%03d' % version}_#{migration_name(name)}.rb"
66
+ end
67
+
68
+ # Takes an assigns hash as the Erubis context. Keys in the hash become
69
+ # instance variable names.
70
+ def self.write_migration(context, source, destination)
71
+ code = Erubis::Eruby.new( File.read( source ) ).evaluate( context )
72
+ puts "Creating #{destination}"
73
+ File.write( destination, code )
74
+ end
75
+
76
+ end
77
+ end
78
+
79
+ end
@@ -0,0 +1,86 @@
1
+ module Waves
2
+ module Layers
3
+ module ORM # :nodoc:
4
+
5
+ # Sets up the Sequel connection and configures AutoCode on Models, so that constants in that
6
+ # namespace get loaded from file or created as subclasses of Models::Default
7
+ module Sequel
8
+
9
+ # On inclusion, this module:
10
+ # - creates on the application module a database method that establishes the Sequel connection
11
+ # - arranges for autoloading/autocreation of missing constants in the Models namespace
12
+ # - defines Sequel-specific helper methods on Waves::Controllers::Base
13
+ #
14
+ # The controller helper methdods are:
15
+ # - all
16
+ # - find(name)
17
+ # - create
18
+ # - delete(name)
19
+ # - update(name)
20
+ #
21
+ def self.included(app)
22
+
23
+ gem 'sequel', '>= 2.0.0'
24
+ require 'sequel'
25
+ require "#{File.dirname(__FILE__)}/sequel/tasks/schema" if defined?(Rake)
26
+ require "#{File.dirname(__FILE__)}/sequel/tasks/generate" if defined?(Rake)
27
+
28
+ def app.database ; @sequel ||= ::Sequel.open( config.database ) ; end
29
+
30
+ app.auto_create_module( :Models ) do
31
+ include AutoCode
32
+ auto_create_class :Default, ::Sequel::Model
33
+ auto_load :Default, :directories => [ :models ]
34
+ end
35
+
36
+ app.auto_eval :Models do
37
+ auto_create_class true, app::Models::Default
38
+ auto_load true, :directories => [ :models ]
39
+ # set the Sequel dataset based on the model class name
40
+ # note that this is not done for app::Models::Default, as it isn't
41
+ # supposed to represent a table
42
+ auto_eval true do
43
+ default = superclass.basename.snake_case.pluralize.intern
44
+ if @dataset && @dataset.opts[:from] != [ default ]
45
+ # don't clobber dataset from autoloaded file
46
+ else
47
+ set_dataset Waves.application.database[ basename.snake_case.pluralize.intern ]
48
+ end
49
+ end
50
+ end
51
+
52
+ Waves::Controllers::Base.instance_eval do
53
+ include Waves::Layers::ORM::Sequel::ControllerMethods
54
+ end
55
+
56
+ end
57
+
58
+ # Mixed into Waves::Controllers::Base. Provides ORM-specific helper methods for model access.
59
+ module ControllerMethods
60
+ def all
61
+ model.all
62
+ end
63
+
64
+ def find( name )
65
+ model[ :name => name ] or not_found
66
+ end
67
+
68
+ def create
69
+ model.create( attributes )
70
+ end
71
+
72
+ def delete( name )
73
+ find( name ).destroy
74
+ end
75
+
76
+ def update( name )
77
+ instance = find( name )
78
+ instance.update_with_params( attributes )
79
+ instance
80
+ end
81
+ end
82
+
83
+ end
84
+ end
85
+ end
86
+ end