Class: Preact::Component::Props
Instance Method Summary
collapse
Constructor Details
#initialize(native) ⇒ Props
4
5
6
|
# File 'lib/preact/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/preact/component/props.rb', line 8
def method_missing(prop, *args, &block)
%x{
const p = #@native.props;
if (typeof p[prop] === 'undefined') {
prop = Opal.Preact.lower_camelize(prop);
if (typeof p[prop] === 'undefined') { return nil; }
}
return p[prop];
}
end
|
Instance Method Details
19
20
21
|
# File 'lib/preact/component/props.rb', line 19
def children
@native.JS[:props].JS[:children]
end
|
#isomorfeus_store ⇒ Object
23
24
25
26
|
# File 'lib/preact/component/props.rb', line 23
def isomorfeus_store
@native.JS[:props].JS[:isomorfeus_store]
end
|
32
33
34
35
36
|
# File 'lib/preact/component/props.rb', line 32
def params
return @params if @params
return nil if `typeof #@native.props.params === 'undefined'`
@params = ::Preact::Component::Params.new(`#@native.props.params`)
end
|
28
29
30
|
# File 'lib/preact/component/props.rb', line 28
def theme
`#@native.props.iso_theme`
end
|
38
39
40
|
# File 'lib/preact/component/props.rb', line 38
def to_h
`Opal.Hash.$new(#@native.props)`.transform_keys!(&:underscore)
end
|
42
43
44
|
# File 'lib/preact/component/props.rb', line 42
def to_json
JSON.dump(to_transport)
end
|
46
47
48
|
# File 'lib/preact/component/props.rb', line 46
def to_n
@native.JS[:props]
end
|
#to_transport ⇒ Object
50
51
52
|
# File 'lib/preact/component/props.rb', line 50
def to_transport
{}.merge(to_h)
end
|