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
|
# File 'lib/react/component/props.rb', line 8
def method_missing(prop, *args, &block)
%x{
if (typeof #@native.props[prop] === 'undefined') {
prop = Opal.React.lower_camelize(prop);
if (typeof #@native.props[prop] === 'undefined') { return #{nil}; }
}
return #@native.props[prop];
}
end
|
Instance Method Details
18
19
20
|
# File 'lib/react/component/props.rb', line 18
def classes
@classes ||= React::Component::Styles.new(@native, 'classes')
end
|
31
32
33
34
35
36
37
38
39
|
# File 'lib/react/component/props.rb', line 31
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
26
27
28
|
# File 'lib/react/component/props.rb', line 26
def isomorfeus_store
@native.JS[:props].JS[:isomorfeus_store]
end
|
41
42
43
44
45
46
47
48
49
|
# File 'lib/react/component/props.rb', line 41
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
|
51
52
53
54
55
56
57
58
59
|
# File 'lib/react/component/props.rb', line 51
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
|
22
23
24
|
# File 'lib/react/component/props.rb', line 22
def theme
@theme ||= React::Component::Styles.new(@native, 'theme')
end
|
61
62
63
|
# File 'lib/react/component/props.rb', line 61
def to_h
`Opal.Hash.$new(#@native.props)`.transform_keys!(&:underscore)
end
|
65
66
67
|
# File 'lib/react/component/props.rb', line 65
def to_json
JSON.dump(to_transport)
end
|
69
70
71
|
# File 'lib/react/component/props.rb', line 69
def to_n
@native.JS[:props]
end
|
#to_transport ⇒ Object
73
74
75
|
# File 'lib/react/component/props.rb', line 73
def to_transport
{}.merge(to_h)
end
|