Class: React::Component::Props
Instance Method Summary
collapse
Constructor Details
#initialize(native) ⇒ Props
Returns a new instance of Props.
4
5
6
|
# File 'lib/react/component/props.rb', line 4
def initialize(native)
@native = native
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(prop, *args, &block) ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/react/component/props.rb', line 8
def method_missing(prop, *args, &block)
%x{
const p = #@native.props;
if (typeof p[prop] === 'undefined') {
prop = Opal.React.lower_camelize(prop);
if (typeof p[prop] === 'undefined') { return nil; }
}
return p[prop];
}
end
|
Instance Method Details
23
24
25
|
# File 'lib/react/component/props.rb', line 23
def children
@native.JS[:props].JS[:children]
end
|
19
20
21
|
# File 'lib/react/component/props.rb', line 19
def classes
@classes ||= React::Component::Styles.new(@native, 'classes')
end
|
36
37
38
39
40
41
42
43
44
|
# File 'lib/react/component/props.rb', line 36
def history
return @history if @history
return nil if `typeof #@native.props.history === 'undefined'`
if `typeof #@native.props.history.action !== 'undefined'`
@history = React::Component::History.new(@native)
else
@native.JS[:props].JS[:history]
end
end
|
#isomorfeus_store ⇒ Object
31
32
33
|
# File 'lib/react/component/props.rb', line 31
def isomorfeus_store
@native.JS[:props].JS[:isomorfeus_store]
end
|
46
47
48
49
50
51
52
53
54
|
# File 'lib/react/component/props.rb', line 46
def location
return @location if @location
return nil if `typeof #@native.props.location === 'undefined'`
if `typeof #@native.props.location.pathname !== 'undefined'`
@location = React::Component::Location.new(@native)
else
@native.JS[:props].JS[:location]
end
end
|
56
57
58
59
60
61
62
63
64
|
# File 'lib/react/component/props.rb', line 56
def match
return @match if @match
return nil if `typeof #@native.props.match === 'undefined'`
if `typeof #@native.props.match.path !== 'undefined'`
@match = React::Component::Match.new(@native)
else
@native.JS[:props].JS[:match]
end
end
|
27
28
29
|
# File 'lib/react/component/props.rb', line 27
def theme
@theme ||= React::Component::Styles.new(@native, 'theme')
end
|
66
67
68
|
# File 'lib/react/component/props.rb', line 66
def to_h
`Opal.Hash.$new(#@native.props)`.transform_keys!(&:underscore)
end
|
70
71
72
|
# File 'lib/react/component/props.rb', line 70
def to_json
JSON.dump(to_transport)
end
|
74
75
76
|
# File 'lib/react/component/props.rb', line 74
def to_n
@native.JS[:props]
end
|
#to_transport ⇒ Object
78
79
80
|
# File 'lib/react/component/props.rb', line 78
def to_transport
{}.merge(to_h)
end
|