innate 2009.04.12 → 2009.05
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +10 -0
- data/CHANGELOG +360 -0
- data/MANIFEST +8 -8
- data/README.md +1 -9
- data/Rakefile +7 -5
- data/example/app/whywiki_erb/start.rb +1 -1
- data/innate.gemspec +9 -5
- data/lib/innate.rb +6 -13
- data/lib/innate/action.rb +29 -33
- data/lib/innate/cache.rb +1 -1
- data/lib/innate/cache/drb.rb +5 -5
- data/lib/innate/cache/file_based.rb +3 -0
- data/lib/innate/cache/marshal.rb +4 -1
- data/lib/innate/cache/memory.rb +1 -2
- data/lib/innate/cache/yaml.rb +4 -1
- data/lib/innate/current.rb +11 -13
- data/lib/innate/dynamap.rb +5 -0
- data/lib/innate/helper.rb +11 -9
- data/lib/innate/helper/aspect.rb +9 -9
- data/lib/innate/helper/cgi.rb +3 -0
- data/lib/innate/helper/link.rb +2 -2
- data/lib/innate/helper/redirect.rb +1 -1
- data/lib/innate/helper/render.rb +70 -7
- data/lib/innate/helper/send_file.rb +9 -1
- data/lib/innate/log/color_formatter.rb +19 -13
- data/lib/innate/node.rb +38 -35
- data/lib/innate/options/dsl.rb +5 -2
- data/lib/innate/request.rb +1 -1
- data/lib/innate/response.rb +1 -7
- data/lib/innate/route.rb +4 -0
- data/lib/innate/session.rb +16 -14
- data/lib/innate/state.rb +10 -11
- data/lib/innate/state/accessor.rb +8 -8
- data/lib/innate/traited.rb +15 -10
- data/lib/innate/version.rb +1 -1
- data/lib/innate/view.rb +41 -4
- data/lib/innate/view/erb.rb +1 -2
- data/lib/innate/view/etanni.rb +9 -12
- data/spec/innate/action/layout.rb +0 -3
- data/spec/innate/helper/flash.rb +0 -3
- data/spec/innate/helper/link.rb +8 -0
- data/spec/innate/helper/redirect.rb +11 -0
- data/spec/innate/helper/render.rb +32 -0
- data/spec/innate/node/node.rb +1 -0
- data/spec/innate/options.rb +5 -1
- data/tasks/authors.rake +30 -0
- data/tasks/release.rake +48 -9
- data/tasks/ycov.rake +84 -0
- metadata +21 -13
- data/lib/innate/core_compatibility/basic_object.rb +0 -10
- data/lib/innate/core_compatibility/string.rb +0 -3
- data/lib/innate/state/fiber.rb +0 -74
- data/lib/innate/state/thread.rb +0 -47
- data/spec/innate/state/fiber.rb +0 -58
- data/spec/innate/state/thread.rb +0 -40
data/Rakefile
CHANGED
@@ -4,11 +4,10 @@ require 'rake/gempackagetask'
|
|
4
4
|
require 'time'
|
5
5
|
require 'date'
|
6
6
|
|
7
|
-
|
8
|
-
specs -= Dir['spec/innate/cache/common.rb']
|
9
|
-
PROJECT_SPECS = specs
|
7
|
+
PROJECT_SPECS = FileList['spec/{innate,example}/**/*.rb'].exclude('common.rb')
|
10
8
|
PROJECT_MODULE = 'Innate'
|
11
9
|
PROJECT_README = 'README.md'
|
10
|
+
PROJECT_VERSION = ENV['VERSION'] || Date.today.strftime('%Y.%m.%d')
|
12
11
|
|
13
12
|
GEMSPEC = Gem::Specification.new{|s|
|
14
13
|
s.name = 'innate'
|
@@ -18,12 +17,15 @@ GEMSPEC = Gem::Specification.new{|s|
|
|
18
17
|
s.email = 'm.fellinger@gmail.com'
|
19
18
|
s.homepage = 'http://github.com/manveru/innate'
|
20
19
|
s.platform = Gem::Platform::RUBY
|
21
|
-
s.version =
|
20
|
+
s.version = PROJECT_VERSION
|
22
21
|
s.files = `git ls-files`.split("\n").sort
|
23
22
|
s.has_rdoc = true
|
24
23
|
s.require_path = 'lib'
|
24
|
+
s.rubyforge_project = "innate"
|
25
25
|
|
26
|
-
|
26
|
+
s.add_dependency('rack', '~> 1.0.0')
|
27
|
+
|
28
|
+
# rip those out if they cause you trouble
|
27
29
|
# s.add_development_dependency('bacon', '>= 1.0')
|
28
30
|
# s.add_development_dependency('json', '~> 1.1.3')
|
29
31
|
# s.add_development_dependency('rack-test', '>= 0.1.0')
|
data/innate.gemspec
CHANGED
@@ -2,27 +2,31 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{innate}
|
5
|
-
s.version = "2009.
|
5
|
+
s.version = "2009.05"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Michael 'manveru' Fellinger"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-05-07}
|
10
10
|
s.description = %q{Simple, straight-forward base for web-frameworks.}
|
11
11
|
s.email = %q{m.fellinger@gmail.com}
|
12
|
-
s.files = ["CHANGELOG", "COPYING", "MANIFEST", "README.md", "Rakefile", "example/app/retro_games.rb", "example/app/todo/layout/default.
|
12
|
+
s.files = ["AUTHORS", "CHANGELOG", "COPYING", "MANIFEST", "README.md", "Rakefile", "example/app/retro_games.rb", "example/app/todo/layout/default.xhtml", "example/app/todo/spec/todo.rb", "example/app/todo/start.rb", "example/app/todo/view/index.xhtml", "example/app/whywiki_erb/layout/wiki.html.erb", "example/app/whywiki_erb/spec/wiki.rb", "example/app/whywiki_erb/start.rb", "example/app/whywiki_erb/view/edit.erb", "example/app/whywiki_erb/view/index.erb", "example/custom_middleware.rb", "example/hello.rb", "example/howto_spec.rb", "example/link.rb", "example/provides.rb", "example/session.rb", "innate.gemspec", "lib/innate.rb", "lib/innate/action.rb", "lib/innate/adapter.rb", "lib/innate/cache.rb", "lib/innate/cache/api.rb", "lib/innate/cache/drb.rb", "lib/innate/cache/file_based.rb", "lib/innate/cache/marshal.rb", "lib/innate/cache/memory.rb", "lib/innate/cache/yaml.rb", "lib/innate/current.rb", "lib/innate/dynamap.rb", "lib/innate/helper.rb", "lib/innate/helper/aspect.rb", "lib/innate/helper/cgi.rb", "lib/innate/helper/flash.rb", "lib/innate/helper/link.rb", "lib/innate/helper/redirect.rb", "lib/innate/helper/render.rb", "lib/innate/helper/send_file.rb", "lib/innate/log.rb", "lib/innate/log/color_formatter.rb", "lib/innate/log/hub.rb", "lib/innate/middleware_compiler.rb", "lib/innate/mock.rb", "lib/innate/node.rb", "lib/innate/options.rb", "lib/innate/options/dsl.rb", "lib/innate/options/stub.rb", "lib/innate/request.rb", "lib/innate/response.rb", "lib/innate/route.rb", "lib/innate/session.rb", "lib/innate/session/flash.rb", "lib/innate/spec.rb", "lib/innate/state.rb", "lib/innate/state/accessor.rb", "lib/innate/traited.rb", "lib/innate/trinity.rb", "lib/innate/version.rb", "lib/innate/view.rb", "lib/innate/view/erb.rb", "lib/innate/view/etanni.rb", "lib/innate/view/none.rb", "spec/example/app/retro_games.rb", "spec/example/hello.rb", "spec/example/link.rb", "spec/example/provides.rb", "spec/example/session.rb", "spec/helper.rb", "spec/innate/action/layout.rb", "spec/innate/action/layout/file_layout.xhtml", "spec/innate/cache/common.rb", "spec/innate/cache/marshal.rb", "spec/innate/cache/memory.rb", "spec/innate/cache/yaml.rb", "spec/innate/dynamap.rb", "spec/innate/helper.rb", "spec/innate/helper/aspect.rb", "spec/innate/helper/cgi.rb", "spec/innate/helper/flash.rb", "spec/innate/helper/link.rb", "spec/innate/helper/redirect.rb", "spec/innate/helper/render.rb", "spec/innate/helper/send_file.rb", "spec/innate/helper/view/aspect_hello.xhtml", "spec/innate/helper/view/locals.xhtml", "spec/innate/helper/view/loop.xhtml", "spec/innate/helper/view/num.xhtml", "spec/innate/helper/view/partial.xhtml", "spec/innate/helper/view/recursive.xhtml", "spec/innate/mock.rb", "spec/innate/node/mapping.rb", "spec/innate/node/node.rb", "spec/innate/node/resolve.rb", "spec/innate/node/view/another_layout/another_layout.xhtml", "spec/innate/node/view/bar.xhtml", "spec/innate/node/view/foo.html.xhtml", "spec/innate/node/view/only_view.xhtml", "spec/innate/node/view/with_layout.xhtml", "spec/innate/node/wrap_action_call.rb", "spec/innate/options.rb", "spec/innate/parameter.rb", "spec/innate/provides.rb", "spec/innate/provides/list.html.xhtml", "spec/innate/provides/list.txt.xhtml", "spec/innate/request.rb", "spec/innate/route.rb", "spec/innate/session.rb", "spec/innate/traited.rb", "tasks/authors.rake", "tasks/bacon.rake", "tasks/changelog.rake", "tasks/gem.rake", "tasks/gem_installer.rake", "tasks/grancher.rake", "tasks/install_dependencies.rake", "tasks/manifest.rake", "tasks/rcov.rake", "tasks/release.rake", "tasks/reversion.rake", "tasks/setup.rake", "tasks/ycov.rake"]
|
13
13
|
s.has_rdoc = true
|
14
14
|
s.homepage = %q{http://github.com/manveru/innate}
|
15
15
|
s.require_paths = ["lib"]
|
16
|
-
s.
|
16
|
+
s.rubyforge_project = %q{innate}
|
17
|
+
s.rubygems_version = %q{1.3.2}
|
17
18
|
s.summary = %q{Powerful web-framework wrapper for Rack.}
|
18
19
|
|
19
20
|
if s.respond_to? :specification_version then
|
20
21
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
21
|
-
s.specification_version =
|
22
|
+
s.specification_version = 3
|
22
23
|
|
23
24
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
25
|
+
s.add_runtime_dependency(%q<rack>, ["~> 1.0.0"])
|
24
26
|
else
|
27
|
+
s.add_dependency(%q<rack>, ["~> 1.0.0"])
|
25
28
|
end
|
26
29
|
else
|
30
|
+
s.add_dependency(%q<rack>, ["~> 1.0.0"])
|
27
31
|
end
|
28
32
|
end
|
data/lib/innate.rb
CHANGED
@@ -3,11 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# Name-space of Innate, just about everything goes in here.
|
5
5
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# * Logger::ColorFormatter
|
9
|
-
# * In 1.8, we define ::BasicObject
|
10
|
-
# * In 1.9, we define ::String#each
|
6
|
+
# The only exception is Logger::ColorFormatter.
|
11
7
|
#
|
12
8
|
module Innate
|
13
9
|
ROOT = File.expand_path(File.dirname(__FILE__))
|
@@ -17,23 +13,20 @@ module Innate
|
|
17
13
|
end
|
18
14
|
|
19
15
|
# stdlib
|
20
|
-
require 'pp'
|
21
|
-
require 'set'
|
22
|
-
require 'pathname'
|
23
16
|
require 'digest/sha1'
|
24
17
|
require 'digest/sha2'
|
18
|
+
require 'find'
|
25
19
|
require 'ipaddr'
|
26
|
-
require 'socket'
|
27
20
|
require 'logger'
|
21
|
+
require 'pathname'
|
22
|
+
require 'pp'
|
23
|
+
require 'set'
|
24
|
+
require 'socket'
|
28
25
|
require 'uri'
|
29
26
|
|
30
27
|
# 3rd party
|
31
28
|
require 'rack'
|
32
29
|
|
33
|
-
# innate's ruby core patches
|
34
|
-
require 'innate/core_compatibility/string'
|
35
|
-
require 'innate/core_compatibility/basic_object'
|
36
|
-
|
37
30
|
# innate core
|
38
31
|
require 'innate/version'
|
39
32
|
require 'innate/traited'
|
data/lib/innate/action.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Innate
|
2
|
-
ACTION_MEMBERS = [ :node, :
|
3
|
-
:
|
2
|
+
ACTION_MEMBERS = [ :node, :instance, :method, :params, :method_value, :view,
|
3
|
+
:view_value, :layout, :wish, :options, :variables, :engine, :path ]
|
4
4
|
|
5
5
|
class Action < Struct.new(*ACTION_MEMBERS)
|
6
6
|
# Create a new Action instance.
|
@@ -32,10 +32,7 @@ module Innate
|
|
32
32
|
# @api stable
|
33
33
|
# @author manveru
|
34
34
|
def call
|
35
|
-
Current.actions
|
36
|
-
render
|
37
|
-
ensure
|
38
|
-
Current.actions.delete(self)
|
35
|
+
Current.actions ? wrap_in_current{ render } : render
|
39
36
|
end
|
40
37
|
|
41
38
|
# @return [Binding] binding of the instance for this Action
|
@@ -67,31 +64,16 @@ module Innate
|
|
67
64
|
from_action
|
68
65
|
end
|
69
66
|
|
70
|
-
|
71
|
-
|
72
|
-
instance_variable_set("@#{iv}", value)
|
73
|
-
end'.strip.freeze
|
74
|
-
|
75
|
-
# Copy Action#variables as instance variables into the given binding.
|
67
|
+
# Copy Action#variables as instance variables into the given object.
|
68
|
+
# Defaults to copying the variables to self.
|
76
69
|
#
|
77
|
-
#
|
78
|
-
# on Innate::Current::actions order.
|
79
|
-
# So we avoid nasty business with Objectspace#_id2ref which may not work on
|
80
|
-
# all ruby implementations and seems to cause other problems as well.
|
81
|
-
#
|
82
|
-
# @param [Binding #eval] binding
|
70
|
+
# @param [Object #instance_variable_set] object
|
83
71
|
# @return [NilClass] there is no indication of failure or success
|
84
|
-
# @see
|
72
|
+
# @see Action#render
|
85
73
|
# @author manveru
|
86
|
-
def copy_variables(
|
87
|
-
|
88
|
-
|
89
|
-
STATE.sync do
|
90
|
-
STATE[:action_variables] = self.variables
|
91
|
-
|
92
|
-
eval(COPY_VARIABLES, binding)
|
93
|
-
|
94
|
-
STATE[:action_variables] = nil
|
74
|
+
def copy_variables(object)
|
75
|
+
self.variables.each do |iv, value|
|
76
|
+
object.instance_variable_set("@#{iv}", value)
|
95
77
|
end
|
96
78
|
end
|
97
79
|
|
@@ -100,12 +82,12 @@ module Innate
|
|
100
82
|
self.variables[:content] ||= nil
|
101
83
|
|
102
84
|
instance.wrap_action_call(self) do
|
103
|
-
copy_variables # this might need another position
|
104
|
-
self.
|
105
|
-
self.view_value =
|
85
|
+
copy_variables(self.instance) # this might need another position
|
86
|
+
self.method_value = instance.__send__(method, *params) if method
|
87
|
+
self.view_value = View.read(view) if view
|
106
88
|
|
107
89
|
body, content_type = wrap_in_layout{
|
108
|
-
engine.call(self, view_value ||
|
90
|
+
engine.call(self, view_value || method_value || '') }
|
109
91
|
options[:content_type] ||= content_type if content_type
|
110
92
|
body
|
111
93
|
end
|
@@ -116,6 +98,7 @@ module Innate
|
|
116
98
|
|
117
99
|
action = dup
|
118
100
|
action.view, action.method = layout_view_or_method(*layout)
|
101
|
+
action.params = []
|
119
102
|
action.layout = nil
|
120
103
|
action.view_value = nil
|
121
104
|
action.sync_variables(self)
|
@@ -128,13 +111,26 @@ module Innate
|
|
128
111
|
[:layout, :view].include?(name) ? [arg, nil] : [nil, arg]
|
129
112
|
end
|
130
113
|
|
114
|
+
def wrap_in_current
|
115
|
+
Current.actions << self
|
116
|
+
yield
|
117
|
+
ensure
|
118
|
+
Current.actions.delete(self)
|
119
|
+
end
|
120
|
+
|
131
121
|
# Try to figure out a sane name for current action.
|
132
122
|
def name
|
133
123
|
File.basename((method || view).to_s).split('.').first
|
134
124
|
end
|
135
125
|
|
126
|
+
# Path to this action, including params, with the mapping of the current
|
127
|
+
# controller prepended.
|
128
|
+
def full_path
|
129
|
+
File.join(node.mapping, path)
|
130
|
+
end
|
131
|
+
|
136
132
|
def valid?
|
137
|
-
method || view
|
133
|
+
node.needs_method? ? (method && view) : (method || view)
|
138
134
|
end
|
139
135
|
end
|
140
136
|
end
|
data/lib/innate/cache.rb
CHANGED
data/lib/innate/cache/drb.rb
CHANGED
@@ -9,8 +9,7 @@ module Innate
|
|
9
9
|
# example below is using a normal Hash, but it is recommended to use a
|
10
10
|
# thread-safe alternative like SyncHash.
|
11
11
|
#
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# @usage example for DRb server
|
14
13
|
# require 'drb'
|
15
14
|
#
|
16
15
|
# URI = "druby://127.0.0.1:9069"
|
@@ -21,12 +20,13 @@ module Innate
|
|
21
20
|
# DRb.start_service(URI, CACHE)
|
22
21
|
# DRb.thread.join
|
23
22
|
#
|
24
|
-
#
|
23
|
+
# Please note that on some Ruby implementations, access to Hash is not
|
24
|
+
# atomic and you might need to lock around access to avoid race conditions.
|
25
25
|
#
|
26
|
+
# @usage for all caches
|
26
27
|
# Innate.options.cache.default = Innate::Cache::DRb
|
27
28
|
#
|
28
|
-
#
|
29
|
-
#
|
29
|
+
# @usage for sessions only
|
30
30
|
# Innate.options.cache.session = Innate::Cache::DRb
|
31
31
|
class DRb
|
32
32
|
include Cache::API
|
@@ -2,6 +2,9 @@ module Innate
|
|
2
2
|
class Cache
|
3
3
|
|
4
4
|
# Used by caches that serialize their contents to the filesystem.
|
5
|
+
# Right now we do not lock around write access to the file outside of the
|
6
|
+
# process, that means that all FileBased caches are not safe for use if you
|
7
|
+
# need more than one instance of your application.
|
5
8
|
module FileBased
|
6
9
|
attr_reader :filename
|
7
10
|
|
data/lib/innate/cache/marshal.rb
CHANGED
@@ -3,8 +3,11 @@ require 'pstore'
|
|
3
3
|
module Innate
|
4
4
|
class Cache
|
5
5
|
# Keeps every cache in a separate file like this:
|
6
|
-
#
|
7
6
|
# /tmp/innate-cache-marshal/delta-manveru-session.marshal
|
7
|
+
#
|
8
|
+
# The Marshal cache is not safe for use between multiple processes, it is
|
9
|
+
# also slow compared to other caches, so generally the use of it is
|
10
|
+
# discouraged.
|
8
11
|
class Marshal
|
9
12
|
include Cache::API
|
10
13
|
include Cache::FileBased
|
data/lib/innate/cache/memory.rb
CHANGED
data/lib/innate/cache/yaml.rb
CHANGED
@@ -3,8 +3,11 @@ require 'yaml/store'
|
|
3
3
|
module Innate
|
4
4
|
class Cache
|
5
5
|
# Keeps every cache in a separate file like this:
|
6
|
-
#
|
7
6
|
# /tmp/innate-cache-yaml/delta-manveru-session.yaml
|
7
|
+
#
|
8
|
+
# The YAML cache is not safe for use between multiple processes, it is also
|
9
|
+
# very slow compared to other caches, so generally the use of it is
|
10
|
+
# discouraged.
|
8
11
|
class YAML
|
9
12
|
include Cache::API
|
10
13
|
include Cache::FileBased
|
data/lib/innate/current.rb
CHANGED
@@ -2,9 +2,9 @@ require 'innate/request'
|
|
2
2
|
require 'innate/response'
|
3
3
|
|
4
4
|
module Innate
|
5
|
-
#
|
6
|
-
# reach them from anywhere in the code without passing around the
|
7
|
-
# directly.
|
5
|
+
# We track the current request/response/session (Trinity) in Thread.current
|
6
|
+
# so we can reach them from anywhere in the code without passing around the
|
7
|
+
# objects directly.
|
8
8
|
class Current
|
9
9
|
extend Trinity
|
10
10
|
|
@@ -16,22 +16,20 @@ module Innate
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
#
|
20
|
-
|
19
|
+
# Run setup and call the app
|
21
20
|
def call(env)
|
22
|
-
|
23
|
-
|
24
|
-
@app.call(env)
|
25
|
-
end
|
21
|
+
setup(env)
|
22
|
+
@app.call(env)
|
26
23
|
end
|
27
24
|
|
28
25
|
# Setup new Request/Response/Session for this request/response cycle.
|
29
26
|
# The parameters are here to allow Ramaze to inject its own classes.
|
30
27
|
def setup(env, request = Request, response = Response, session = Session)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
current = Thread.current
|
29
|
+
req = current[:request] = request.new(env)
|
30
|
+
res = current[:response] = response.new
|
31
|
+
current[:actions] = []
|
32
|
+
current[:session] = Session.new(req, res)
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
data/lib/innate/dynamap.rb
CHANGED
data/lib/innate/helper.rb
CHANGED
@@ -152,10 +152,10 @@ module Innate
|
|
152
152
|
# helper :foo_bar # => FooBar
|
153
153
|
# helper :foo # => Foo
|
154
154
|
def get(name)
|
155
|
-
|
155
|
+
module_name = /^#{name.to_s.dup.delete('_')}$/i
|
156
156
|
|
157
157
|
options.namespaces.each do |namespace|
|
158
|
-
found = namespace.constants.grep(
|
158
|
+
found = namespace.constants.grep(module_name).first
|
159
159
|
return namespace.const_get(found) if found
|
160
160
|
end
|
161
161
|
|
@@ -165,19 +165,21 @@ module Innate
|
|
165
165
|
# Figure out files that might have the helper we ask for and then require
|
166
166
|
# the first we find, if any.
|
167
167
|
def try_require(name)
|
168
|
-
if found =
|
168
|
+
if found = find_helper(name.to_s)
|
169
169
|
require(found) || true
|
170
170
|
else
|
171
171
|
raise(LoadError, "Helper #{name} not found")
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
175
|
+
def find_helper(name)
|
176
|
+
options.paths.uniq.find do |path|
|
177
|
+
base = ::File.join(path, 'helper', name)
|
178
|
+
options.exts.find do |ext|
|
179
|
+
full = "#{base}.#{ext}"
|
180
|
+
return full if ::File.file?(full)
|
181
|
+
end
|
182
|
+
end
|
181
183
|
end
|
182
184
|
end
|
183
185
|
end
|
data/lib/innate/helper/aspect.rb
CHANGED
@@ -94,28 +94,28 @@ module Innate
|
|
94
94
|
AOP[self][:before_all] = block
|
95
95
|
end
|
96
96
|
|
97
|
-
def before(
|
98
|
-
AOP[self][:before][name] = block
|
97
|
+
def before(*names, &block)
|
98
|
+
names.each{|name| AOP[self][:before][name] = block }
|
99
99
|
end
|
100
100
|
|
101
101
|
def after_all(&block)
|
102
102
|
AOP[self][:after_all] = block
|
103
103
|
end
|
104
104
|
|
105
|
-
def after(
|
106
|
-
AOP[self][:after][name] = block
|
105
|
+
def after(*names, &block)
|
106
|
+
names.each{|name| AOP[self][:after][name] = block }
|
107
107
|
end
|
108
108
|
|
109
|
-
def wrap(
|
110
|
-
before(
|
111
|
-
after(
|
109
|
+
def wrap(*names, &block)
|
110
|
+
before(*names, &block)
|
111
|
+
after(*names, &block)
|
112
112
|
end
|
113
113
|
|
114
114
|
def add_action_wrapper(order, method_name)
|
115
115
|
if wrap = trait[:wrap]
|
116
|
-
wrap.merge(SortedSet[[order, method_name]])
|
116
|
+
wrap.merge(SortedSet[[order, method_name.to_s]])
|
117
117
|
else
|
118
|
-
trait :wrap => SortedSet[[order, method_name]]
|
118
|
+
trait :wrap => SortedSet[[order, method_name.to_s]]
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|