basic_assumption 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.rdoc
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
== 0.3.10 / 2010-06-18
|
2
|
+
* License
|
3
|
+
* Rename LICENSE to MIT-LICENSE; terms remain the same
|
4
|
+
* Bug Fix
|
5
|
+
* Fix issue where BasicAssumption was unusable outside of Rails due to accidental ActiveSupport dependency
|
6
|
+
== 0.3.9 / 2010-06-05
|
7
|
+
* Feature Change
|
8
|
+
* RestfulRails works first based on the plurality of the name passed to assume and then the presence of id in params
|
9
|
+
* Test Enhancement
|
10
|
+
* RestfulRails specs for all combinations of 7 RESTful actions, singular/plural name, and presence of id in params
|
11
|
+
== 0.3.8 / 2010-06-05
|
12
|
+
* Feature Change
|
13
|
+
* Specify default when calling assume by passing :using => :default instead of :with => :default
|
data/{LICENSE → MIT-LICENSE}
RENAMED
File without changes
|
data/README.rdoc
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
== BasicAssumption
|
2
2
|
|
3
|
-
BasicAssumption is a gem
|
4
|
-
in a concise manner. It is
|
5
|
-
cleaner.
|
3
|
+
BasicAssumption is a gem that lets you declare resources inside of a class
|
4
|
+
in a concise manner. It is meant to make Rails controllers and views cleaner.
|
6
5
|
|
7
6
|
It is a clone of DecentExposure that adds a psuedo-modular interface for
|
8
7
|
providing custom defaults and some useful defaults out of the box.
|
@@ -94,8 +93,8 @@ A named resource created with +assume+ may be used in multiple controller
|
|
94
93
|
actions, or the same view template or partial referencing the named
|
95
94
|
resource may be rendered by more than one action. There will be times when
|
96
95
|
the behavior given to +assume+ is correct for most cases save one or two. It's
|
97
|
-
possible to override the value
|
98
|
-
action to accommodate an exceptional case more easily. For example:
|
96
|
+
possible to override the value returned by the resource method within a
|
97
|
+
particular action to accommodate an exceptional case more easily. For example:
|
99
98
|
|
100
99
|
class WidgetController < ActionController::Base
|
101
100
|
assume :widget
|
@@ -124,9 +123,7 @@ app, please see the BasicAssumption::Railtie documentation.
|
|
124
123
|
|
125
124
|
Whenever you find yourself writing a +before_filter+ in a Rails controller
|
126
125
|
that sets instance variables as part of the context of your request, you should
|
127
|
-
probably use an assumption instead.
|
128
|
-
lazy evaluation, there's no need to worry about avoiding calls on actions that
|
129
|
-
don't need some particular setup.
|
126
|
+
probably use an assumption instead.
|
130
127
|
|
131
128
|
For example, this:
|
132
129
|
|
@@ -148,9 +145,12 @@ would become this:
|
|
148
145
|
end
|
149
146
|
|
150
147
|
and would provide the added benefit of not tossing instance variables around.
|
148
|
+
Because BasicAssumption is written to use lazy evaluation, there's no need to
|
149
|
+
worry about avoiding calls on actions that don't need some particular setup.
|
150
|
+
|
151
151
|
If a controller has protected or hidden methods that find or create instance
|
152
152
|
variables used in actions and/or views, it might be cleaner to use an
|
153
|
-
assumption
|
153
|
+
assumption. This:
|
154
154
|
|
155
155
|
class CompanyController < ActionController::Base
|
156
156
|
|
@@ -35,7 +35,7 @@ module BasicAssumption
|
|
35
35
|
def self.resolve(klass) #:nodoc:
|
36
36
|
return strategy(klass) if klass.kind_of?(Symbol)
|
37
37
|
while !registry.has_key?(klass.object_id)
|
38
|
-
klass = klass
|
38
|
+
klass = superclass(klass)
|
39
39
|
break if klass.nil?
|
40
40
|
end
|
41
41
|
registry[klass.object_id]
|
@@ -59,6 +59,12 @@ module BasicAssumption
|
|
59
59
|
Base.new.block
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def superclass(klass)
|
66
|
+
klass.ancestors[1]
|
67
|
+
end
|
62
68
|
end
|
63
69
|
end
|
64
70
|
end
|
@@ -29,7 +29,7 @@ describe BasicAssumption::DefaultAssumption do
|
|
29
29
|
mod.send(:strategy, :rails).should eql(:block)
|
30
30
|
end
|
31
31
|
it "returns the block of a Base instance otherwise" do
|
32
|
-
mod.send(:strategy, nil).call.should be_nil
|
32
|
+
mod.send(:strategy, nil).call(:foo).should be_nil
|
33
33
|
end
|
34
34
|
end
|
35
35
|
describe "::registry" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 10
|
9
|
+
version: 0.3.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Matt Yoho
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-18 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -66,10 +66,12 @@ executables: []
|
|
66
66
|
extensions: []
|
67
67
|
|
68
68
|
extra_rdoc_files:
|
69
|
-
-
|
69
|
+
- HISTORY.rdoc
|
70
|
+
- MIT-LICENSE
|
70
71
|
- README.rdoc
|
71
72
|
files:
|
72
|
-
-
|
73
|
+
- HISTORY.rdoc
|
74
|
+
- MIT-LICENSE
|
73
75
|
- README.rdoc
|
74
76
|
- lib/basic_assumption.rb
|
75
77
|
- lib/basic_assumption/configuration.rb
|