expose_model 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/lib/expose_model.rb +2 -13
- data/lib/expose_model/action_view.rb +4 -0
- data/lib/expose_model/expose_model.rb +16 -3
- metadata +1 -1
data/History.txt
CHANGED
data/lib/expose_model.rb
CHANGED
@@ -1,17 +1,6 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
-
$:.include?(File.dirname(__FILE__)) ||
|
3
|
-
|
4
|
-
require 'action_controller'
|
5
|
-
require 'action_view'
|
2
|
+
$:.include?(File.dirname(__FILE__)) ||
|
3
|
+
$:.include?(File.expand_path(File.dirname(__FILE__)))
|
6
4
|
|
7
5
|
require 'expose_model/expose_model'
|
8
6
|
require 'expose_model/action_view'
|
9
|
-
|
10
|
-
# Stop sharing so much!
|
11
|
-
ActionController::Base.class_eval { def add_instance_variables_to_assigns; end }
|
12
|
-
# Stop caring so much!
|
13
|
-
ActionView::Base.class_eval { def assign_variables_from_controller; end }
|
14
|
-
|
15
|
-
module ExposeModel
|
16
|
-
VERSION = '0.0.1'
|
17
|
-
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'action_view'
|
2
|
+
|
1
3
|
# raise a 404, not a 500 if we first access the exposed method in a view
|
2
4
|
class ActionView::Template
|
3
5
|
def render_template(view, local_assigns = {})
|
@@ -7,3 +9,5 @@ class ActionView::Template
|
|
7
9
|
raise e
|
8
10
|
end
|
9
11
|
end
|
12
|
+
|
13
|
+
ActionView::Base.class_eval { def assign_variables_from_controller; end }
|
@@ -1,5 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'action_controller'
|
2
|
+
|
3
|
+
module ExposeModel
|
4
|
+
VERSION = '0.0.2'
|
5
|
+
|
6
|
+
def self.included(base) #:nodoc:
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
3
11
|
def expose_model(model = nil)
|
4
12
|
raise ArgumentError.new('expose_model requires a model name') if model.nil?
|
5
13
|
model = model.to_s
|
@@ -27,4 +35,9 @@ class ApplicationController < ActionController::Base
|
|
27
35
|
)
|
28
36
|
end
|
29
37
|
end
|
30
|
-
end
|
38
|
+
end
|
39
|
+
|
40
|
+
ActionController::Base.class_eval {
|
41
|
+
def add_instance_variables_to_assigns; end
|
42
|
+
include ExposeModel
|
43
|
+
}
|