rubyless 0.8.3 → 0.8.4
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 +6 -1
- data/README.rdoc +6 -0
- data/lib/ruby_less/info.rb +1 -1
- data/lib/ruby_less/safe_class.rb +15 -9
- data/rubyless.gemspec +1 -1
- metadata +3 -3
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -65,6 +65,12 @@ You can look at the tests for an idea of how to declare things. If you have more
|
|
65
65
|
|
66
66
|
http://zenadmin.org/community
|
67
67
|
|
68
|
+
== WARNING:
|
69
|
+
|
70
|
+
Changing the safe methods during runtime removes the cache for all classes and
|
71
|
+
should therefore be avoided in favor of dynamic "safe_method_type" methods for the
|
72
|
+
objects/classes concerned.
|
73
|
+
|
68
74
|
== REQUIREMENTS:
|
69
75
|
|
70
76
|
* parse_tree
|
data/lib/ruby_less/info.rb
CHANGED
data/lib/ruby_less/safe_class.rb
CHANGED
@@ -6,7 +6,6 @@ module RubyLess
|
|
6
6
|
|
7
7
|
# List of safe methods for a specific class.
|
8
8
|
def self.safe_methods_for(klass)
|
9
|
-
# Caching safe_methods_all is bad when modules are dynamically added / removed.
|
10
9
|
@@_safe_methods_parsed[klass] ||= build_safe_methods_list(klass)
|
11
10
|
end
|
12
11
|
|
@@ -58,6 +57,9 @@ module RubyLess
|
|
58
57
|
|
59
58
|
# Declare a safe method for a given class ( same as #safe_method)
|
60
59
|
def self.safe_method_for(klass, methods_hash)
|
60
|
+
# This is why defining new safe methods during runtime is BAD.
|
61
|
+
@@_safe_methods_parsed = {} # rebuild all cache
|
62
|
+
|
61
63
|
defaults = methods_hash.delete(:defaults) || {}
|
62
64
|
|
63
65
|
list = (@@_safe_methods[klass] ||= {})
|
@@ -243,16 +245,20 @@ module RubyLess
|
|
243
245
|
def self.build_safe_methods_list(klass)
|
244
246
|
list = SignatureHash.new
|
245
247
|
(@@_safe_methods[klass] || {}).map do |signature, return_value|
|
246
|
-
if return_value.
|
247
|
-
|
248
|
-
elsif return_value.kind_of?(Proc) || return_value.kind_of?(Symbol)
|
249
|
-
# keep
|
248
|
+
if return_value.frozen?
|
249
|
+
# Already parsed, skip
|
250
250
|
else
|
251
|
-
|
251
|
+
if return_value.kind_of?(Hash)
|
252
|
+
return_value[:class] = parse_class(return_value[:class])
|
253
|
+
elsif return_value.kind_of?(Proc) || return_value.kind_of?(Symbol)
|
254
|
+
# keep
|
255
|
+
else
|
256
|
+
return_value = {:class => return_value}
|
257
|
+
end
|
258
|
+
return_value.freeze
|
252
259
|
end
|
253
|
-
|
254
|
-
signature =
|
255
|
-
list[signature] = return_value.freeze
|
260
|
+
signature = [signature.first] + signature[1..-1].map {|e| parse_class(e)}
|
261
|
+
list[signature] = return_value
|
256
262
|
end
|
257
263
|
list
|
258
264
|
end
|
data/rubyless.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 4
|
10
|
+
version: 0.8.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gaspard Bucher
|