Class: React::Component::Props

Inherits:
Object
  • Object
show all
Includes:
Native::Wrapper
Defined in:
lib/react/component/props.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(prop, *args, &block) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/react/component/props.rb', line 6

def method_missing(prop, *args, &block)
  %x{
    var prop_name = Opal.React.lower_camelize(prop);
    if (typeof #@native.props[prop_name] === 'undefined') { return #{nil}; }
    return #@native.props[prop_name];
  }
end

Instance Method Details

#classesObject



14
15
16
# File 'lib/react/component/props.rb', line 14

def classes
  @classes ||= `Opal.React.Component.Styles.$new(#@native.props.classes)`
end

#historyObject

for router convenience



23
24
25
26
27
28
29
30
31
# File 'lib/react/component/props.rb', line 23

def history
  return @history if @history
  return nil unless @native.JS[:props].JS[:history]
  if @native.JS[:props].JS[:history].JS[:pathname]
    @history = React::Component::History.new(@native.JS[:props].JS[:history])
  else
    @native.JS[:props].JS[:history]
  end
end

#isomorfeus_storeObject



18
19
20
# File 'lib/react/component/props.rb', line 18

def isomorfeus_store
  @native.JS[:props].JS[:isomorfeus_store]
end

#locationObject



33
34
35
36
37
38
39
40
41
# File 'lib/react/component/props.rb', line 33

def location
  return @location if @location
  return nil unless @native.JS[:props].JS[:location]
  if @native.JS[:props].JS[:location].JS[:pathname]
    @location = React::Component::Location.new(@native.JS[:props].JS[:location])
  else
    @native.JS[:props].JS[:location]
  end
end

#matchObject



43
44
45
46
47
48
49
50
51
# File 'lib/react/component/props.rb', line 43

def match
  return @match if @match
  return nil unless @native.JS[:props].JS[:match]
  if @native.JS[:props].JS[:match].JS[:path]
    @match = React::Component::Match.new(@native.JS[:props].JS[:match])
  else
    @native.JS[:props].JS[:match]
  end
end

#to_nObject



53
54
55
# File 'lib/react/component/props.rb', line 53

def to_n
  @native.JS[:props]
end