diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-04-22 15:26:03 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-04-22 15:26:03 +0100 |
commit | 5f3f100ce2d689480da85abc88e5e940cf90189e (patch) | |
tree | 15c1a05a5308a9eea56d7f0889ac46d9cac5b57c /actionpack/lib/action_controller/abstract/base.rb | |
parent | d758d996d1b66e2a65640f79f01ce2ac674d7ed5 (diff) | |
parent | ca49299434bc764b667cd86846d892e91a150ef3 (diff) | |
download | rails-5f3f100ce2d689480da85abc88e5e940cf90189e.tar.gz rails-5f3f100ce2d689480da85abc88e5e940cf90189e.tar.bz2 rails-5f3f100ce2d689480da85abc88e5e940cf90189e.zip |
Merge branch 'master' into active_model
Conflicts:
activeresource/lib/active_resource/validations.rb
Diffstat (limited to 'actionpack/lib/action_controller/abstract/base.rb')
-rw-r--r-- | actionpack/lib/action_controller/abstract/base.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/abstract/base.rb b/actionpack/lib/action_controller/abstract/base.rb new file mode 100644 index 0000000000..ade7719cc0 --- /dev/null +++ b/actionpack/lib/action_controller/abstract/base.rb @@ -0,0 +1,41 @@ +module AbstractController + class Base + + attr_internal :response_body + attr_internal :response_obj + attr_internal :action_name + + def self.process(action) + new.process(action) + end + + def self.inherited(klass) + end + + def initialize + self.response_obj = {} + end + + def process(action_name) + unless respond_to_action?(action_name) + raise ActionNotFound, "The action '#{action_name}' could not be found" + end + + @_action_name = action_name + process_action + self.response_obj[:body] = self.response_body + self + end + + private + + def process_action + respond_to?(action_name) ? send(action_name) : send(:action_missing, action_name) + end + + def respond_to_action?(action_name) + respond_to?(action_name) || respond_to?(:action_missing, true) + end + + end +end
\ No newline at end of file |