Class: Pageflow::React::WidgetType

Inherits:
WidgetType show all
Defined in:
lib/pageflow/react/widget_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from WidgetType

#enabled_in_editor?, #enabled_in_preview?, #render_head_fragment, #render_head_fragment_with_configuration, #render_with_configuration, #translation_key

Constructor Details

#initialize(name, role, options = {}) ⇒ WidgetType

Returns a new instance of WidgetType.



6
7
8
9
10
# File 'lib/pageflow/react/widget_type.rb', line 6

def initialize(name, role, options = {})
  @name = name
  @role = role
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/pageflow/react/widget_type.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/pageflow/react/widget_type.rb', line 4

def options
  @options
end

#roleObject (readonly)

Returns the value of attribute role.



4
5
6
# File 'lib/pageflow/react/widget_type.rb', line 4

def role
  @role
end

Instance Method Details

#insert_pointObject



16
17
18
# File 'lib/pageflow/react/widget_type.rb', line 16

def insert_point
  @options[:insert_point] || super
end

#render(template, entry) ⇒ Object



20
21
22
23
24
25
# File 'lib/pageflow/react/widget_type.rb', line 20

def render(template, entry)
  template.render(File.join('pageflow', 'react', 'widget'),
                  entry: entry,
                  name: name,
                  server_rendering: options[:server_rendering])
end

#rolesObject



12
13
14
# File 'lib/pageflow/react/widget_type.rb', line 12

def roles
  [role]
end