Permalink
Browse files

tweak activemodel load order a bit

  • Loading branch information...
1 parent aec3c7a commit b7c6ceff9a31cc478c4bc89d57980900a775fbed @technoweenie technoweenie committed Jun 28, 2008
View
@@ -1,16 +1,24 @@
#!/usr/bin/env ruby
-$LOAD_PATH << File.join(File.dirname(__FILE__), 'vendor', 'rspec', 'lib')
require 'rake'
-require 'spec/rake/spectask'
+require 'rake/testtask'
require 'rake/rdoctask'
+task :default => :test
+
+Rake::TestTask.new do |t|
+ t.libs << "test"
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+ t.warning = true
+end
+
# Generate the RDoc documentation
-Rake::RDocTask.new { |rdoc|
+Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'doc'
rdoc.title = "Active Model"
rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
rdoc.options << '--charset' << 'utf-8'
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
rdoc.rdoc_files.include('README', 'CHANGES')
rdoc.rdoc_files.include('lib/**/*.rb')
-}
+end
@@ -1,17 +1,5 @@
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', '..', 'activesupport', 'lib')
-
-# premature optimization?
-require 'active_support/inflector'
-require 'active_support/core_ext/string/inflections'
-String.send :include, ActiveSupport::CoreExtensions::String::Inflections
-
-require 'active_model/base'
require 'active_model/observing'
-require 'active_model/callbacks'
-require 'active_model/validations'
-
-ActiveModel::Base.class_eval do
- include ActiveModel::Observing
- include ActiveModel::Callbacks
- include ActiveModel::Validations
-end
+# disabled until they're tested
+# require 'active_model/callbacks'
+# require 'active_model/validations'
+require 'active_model/base'
@@ -1,4 +1,8 @@
module ActiveModel
class Base
+ include Observing
+ # disabled, until they're tested
+ # include Callbacks
+ # include Validations
end
end
@@ -1,3 +1,5 @@
+require 'active_model/observing'
+
module ActiveModel
module Callbacks
@@ -0,0 +1,7 @@
+# This file is required by each major ActiveModel component for the core requirements. This allows you to
+# load individual pieces of ActiveModel as needed.
+$LOAD_PATH << File.join(File.dirname(__FILE__), '..', '..', '..', 'activesupport', 'lib')
+
+# premature optimization?
+# So far, we only need the string inflections and not the rest of ActiveSupport.
+require 'active_support/inflector'
@@ -1,4 +1,6 @@
require 'observer'
+require 'singleton'
+require 'active_model/core'
module ActiveModel
module Observing
@@ -73,7 +75,7 @@ def observed_class
# Start observing the declared classes and their subclasses.
def initialize
self.observed_classes = self.class.models if self.class.models
- observed_classes.each { |klass| add_observer! klass }
+ observed_classes.each { |klass| klass.add_observer(self) }
end
# Send observed_method(object) if the method exists.
@@ -85,16 +87,12 @@ def update(observed_method, object) #:nodoc:
# Passes the new subclass.
def observed_class_inherited(subclass) #:nodoc:
self.class.observe(observed_classes + [subclass])
- add_observer!(subclass)
+ subclass.add_observer(self)
end
- protected
- def observed_classes
- @observed_classes ||= [self.class.observed_class]
- end
-
- def add_observer!(klass)
- klass.add_observer(self)
- end
+ protected
+ def observed_classes
+ @observed_classes ||= [self.class.observed_class]
+ end
end
end
@@ -1,3 +1,5 @@
+require 'active_model/observing'
+
module ActiveModel
module Validations
def self.included(base) # :nodoc:

0 comments on commit b7c6cef

Please sign in to comment.