Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 5530d7577da82f497842b27f6a0d087218be5c62 0 parents
@jakehow authored
20 MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008 Jake Howerton
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 README
@@ -0,0 +1,28 @@
+ConcernedWith
+=============
+
+Simple way to separate model concerns into separate files. Code is from Rick Olson's altered_beast project.
+
+
+Example
+=======
+
+# app/models/user.rb
+class User < ActiveRecord::Base
+ concerned_with :validations, :authentication
+end
+
+# app/models/user/validations.rb
+class User < ActiveRecord::Base
+ validates_presence_of :name
+end
+
+#app/models/user/authentication.rb
+class User < ActiveRecord::Base
+ def self.authenticate(name, password)
+ find_by_name_and_password(name, password)
+ end
+end
+
+
+Copyright (c) 2008 Jake Howerton, released under the MIT license
22 Rakefile
@@ -0,0 +1,22 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the concerned_with plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the concerned_with plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'ConcernedWith'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
3  init.rb
@@ -0,0 +1,3 @@
+# Include hook code here
+require File.dirname(__FILE__) + '/lib/concerned_with'
+ActiveRecord::Base.send(:extend, ConcernedWith)
1  install.rb
@@ -0,0 +1 @@
+# Install hook code here
8 lib/concerned_with.rb
@@ -0,0 +1,8 @@
+# ConcernedWith
+module ConcernedWith
+ def concerned_with(*concerns)
+ concerns.each do |concern|
+ require_dependency "#{name.underscore}/#{concern}"
+ end
+ end
+end
4 tasks/concerned_with_tasks.rake
@@ -0,0 +1,4 @@
+# desc "Explaining what the task does"
+# task :concerned_with do
+# # Task goes here
+# end
8 test/concerned_with_test.rb
@@ -0,0 +1,8 @@
+require 'test/unit'
+
+class ConcernedWithTest < Test::Unit::TestCase
+ # Replace this with your real tests.
+ def test_this_plugin
+ flunk
+ end
+end
1  uninstall.rb
@@ -0,0 +1 @@
+# Uninstall hook code here
Please sign in to comment.
Something went wrong with that request. Please try again.