reactive-ruby 0.7.16 → 0.7.17
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29fbf083f6ff7680077ff9123a55f40b3212b9e1
|
4
|
+
data.tar.gz: 539e46aaf607d86f535e6ed7f3a78a12188e00e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc3ce82f056121c1ebf795eca5e4d2b165e489d6bb148711599f258e9165aaf9c431cfcc6c578042beb10455670cd9fad4889939934d2c57791d603888fd9402
|
7
|
+
data.tar.gz: 504baa1e1fe8118e848b336758a3ead39a87f3b36a2f044c6d18e74041553e528ea7e9c6de93cde832d70c9cd1bec888d08a4fbae167d33e1d95ae9edc7ef071
|
data/lib/reactive-ruby/api.rb
CHANGED
@@ -76,6 +76,8 @@ module React
|
|
76
76
|
getDefaultProps: function(){
|
77
77
|
return #{type.respond_to?(:default_props) ? type.default_props.to_n : `{}`};
|
78
78
|
},
|
79
|
+
mixins: #{type.respond_to?(:native_mixins) ? type.native_mixins : `[]`},
|
80
|
+
statics: #{type.respond_to?(:static_call_backs) ? type.static_call_backs.to_n : `{}`},
|
79
81
|
componentWillMount: function() {
|
80
82
|
var instance = this._getOpalInstance.apply(this);
|
81
83
|
return #{`instance`.component_will_mount if type.method_defined? :component_will_mount};
|
@@ -154,6 +156,7 @@ module React
|
|
154
156
|
end
|
155
157
|
|
156
158
|
def self.convert_props(properties)
|
159
|
+
raise "Component parameters must be a hash. Instead you sent #{properties}" unless properties.is_a? Hash
|
157
160
|
props = {}
|
158
161
|
properties.map do |key, value|
|
159
162
|
if key == "class_name" && value.is_a?(Hash)
|
@@ -28,7 +28,7 @@ module React
|
|
28
28
|
end unless method_defined? :render
|
29
29
|
|
30
30
|
def children
|
31
|
-
nodes = `#{@native}.props.children`
|
31
|
+
nodes = `#{@native}.props.children` || []
|
32
32
|
class << nodes
|
33
33
|
include Enumerable
|
34
34
|
|
@@ -63,16 +63,23 @@ module React
|
|
63
63
|
base.extend(ClassMethods)
|
64
64
|
|
65
65
|
if base.name
|
66
|
+
#puts "getting parent of #{base.name}"
|
66
67
|
parent = base.name.split("::").inject([Module]) { |nesting, next_const| nesting + [nesting.last.const_get(next_const)] }[-2]
|
67
|
-
|
68
|
-
|
68
|
+
#puts "defining method missing for module #{parent}"
|
69
|
+
|
70
|
+
class << parent #.class_eval do
|
71
|
+
|
72
|
+
|
73
|
+
|
69
74
|
def method_missing(n, *args, &block)
|
75
|
+
#puts "method missing for #{n} called"
|
70
76
|
name = n
|
71
77
|
if name =~ /_as_node$/
|
72
78
|
node_only = true
|
73
79
|
name = name.gsub(/_as_node$/, "")
|
74
80
|
end
|
75
81
|
unless name = const_get(name) and name.method_defined? :render
|
82
|
+
#puts "can't find render method"
|
76
83
|
return super
|
77
84
|
end
|
78
85
|
if node_only
|
@@ -81,6 +88,7 @@ module React
|
|
81
88
|
React::RenderingContext.render(name, *args, &block)
|
82
89
|
end
|
83
90
|
rescue Exception => e
|
91
|
+
puts "pow"
|
84
92
|
message = "#{base.name}.#{n} method_missing handler exception raised: #{e}"
|
85
93
|
`console.error(#{message})`
|
86
94
|
end
|
@@ -327,9 +335,16 @@ module React
|
|
327
335
|
|
328
336
|
def optional_param(name, options = {})
|
329
337
|
validator.optional(name, options)
|
330
|
-
define_param_method(name, options[:type])
|
338
|
+
define_param_method(name, options[:type]) unless name == :params
|
331
339
|
end
|
332
340
|
|
341
|
+
def collect_other_params_as(name)
|
342
|
+
validator.all_others(name)
|
343
|
+
define_method(name) do
|
344
|
+
@_all_others ||= self.class.validator.collect_all_others(params)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
333
348
|
def define_state(*states, &block)
|
334
349
|
default_initial_value = (block and block.arity == 0) ? yield : nil
|
335
350
|
states_hash = (states.last.is_a? Hash) ? states.pop : {}
|
@@ -378,6 +393,22 @@ module React
|
|
378
393
|
end
|
379
394
|
end
|
380
395
|
|
396
|
+
def native_mixin(item)
|
397
|
+
native_mixins << item
|
398
|
+
end
|
399
|
+
|
400
|
+
def native_mixins
|
401
|
+
@native_mixins ||= []
|
402
|
+
end
|
403
|
+
|
404
|
+
def static_call_back(name, &block)
|
405
|
+
static_call_backs[name] = block
|
406
|
+
end
|
407
|
+
|
408
|
+
def static_call_backs
|
409
|
+
@static_call_backs ||= {}
|
410
|
+
end
|
411
|
+
|
381
412
|
def export_component(opts = {})
|
382
413
|
export_name = (opts[:as] || name).split("::")
|
383
414
|
first_name = export_name.first
|
@@ -26,19 +26,35 @@ module React
|
|
26
26
|
@rules[prop_name] = options
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def all_others(prop_name)
|
30
|
+
@all_others = {}
|
31
|
+
end
|
32
|
+
|
33
|
+
def collect_all_others(params)
|
34
|
+
Hash[params.collect { |prop_name, value| [prop_name, value] if @rules[prop_name] == nil}.compact]
|
35
|
+
end
|
36
|
+
|
37
|
+
def type_check(errors, error_prefix, object, klass, nil_allowed)
|
38
|
+
return if !object and nil_allowed
|
30
39
|
is_native = !object.respond_to?(:is_a?) rescue true
|
31
40
|
if is_native or !object.is_a? klass
|
32
|
-
unless klass.respond_to? :_react_param_conversion and klass._react_param_conversion
|
33
|
-
errors << "#{error_prefix} could not be converted to #{klass}"
|
41
|
+
unless klass.respond_to? :_react_param_conversion and klass._react_param_conversion(object, :validate_only)
|
42
|
+
errors << "#{error_prefix} could not be converted to #{klass}"
|
34
43
|
end
|
35
44
|
end
|
36
45
|
end
|
37
46
|
|
38
47
|
def validate(props)
|
39
48
|
errors = []
|
40
|
-
|
41
|
-
|
49
|
+
|
50
|
+
if @all_others
|
51
|
+
props.each do |prop_name, value|
|
52
|
+
@all_others[prop_name] = value if @rules[prop_name] == nil
|
53
|
+
end
|
54
|
+
else
|
55
|
+
props.keys.each do |prop_name|
|
56
|
+
errors << "Provided prop `#{prop_name}` not specified in spec" if @rules[prop_name] == nil
|
57
|
+
end
|
42
58
|
end
|
43
59
|
|
44
60
|
props = props.select {|key| @rules.keys.include?(key) }
|
@@ -54,12 +70,12 @@ module React
|
|
54
70
|
if is_klass_array
|
55
71
|
value_is_array_like = value.respond_to?(:each_with_index) rescue nil
|
56
72
|
if value_is_array_like
|
57
|
-
value.each_with_index { |ele, i| type_check(errors, "Provided prop `#{prop_name}`[#{i}]", ele, klass[0]) }
|
73
|
+
value.each_with_index { |ele, i| type_check(errors, "Provided prop `#{prop_name}`[#{i}]", ele, klass[0], @rules[prop_name][:allow_nil]) }
|
58
74
|
else
|
59
75
|
errors << "Provided prop `#{prop_name}` was not an Array"
|
60
76
|
end
|
61
77
|
else
|
62
|
-
type_check(errors, "Provided prop `#{prop_name}`", value, klass)
|
78
|
+
type_check(errors, "Provided prop `#{prop_name}`", value, klass, @rules[prop_name][:allow_nil])
|
63
79
|
end
|
64
80
|
end
|
65
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reactive-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|