Class: Guide::Structure

Inherits:
Node
  • Object
show all
Defined in:
app/models/guide/structure.rb

Instance Attribute Summary

Attributes inherited from Node

#id, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#==, child_node_class, #child_nodes, contains, #image_path, #initialize, #leaf_node?, #name, #node_type, #view_model

Constructor Details

This class inherits a constructor from Guide::Node

Class Method Details

.inherited(sub_class) ⇒ Object



40
41
42
43
# File 'app/models/guide/structure.rb', line 40

def self.inherited(sub_class)
  sub_class.scenario_definitions = {}
  super(sub_class)
end

.scenario(id, **options, &block) ⇒ Object



29
30
31
32
33
34
35
36
# File 'app/models/guide/structure.rb', line 29

def self.scenario(id, **options, &block)
  private define_method(id, block)

  scenario_definitions[id] = OpenStruct.new(
    :name => id.to_s.titleize,
    :options => OpenStruct.new(**options),
  )
end

Instance Method Details

#can_be_rendered?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/models/guide/structure.rb', line 66

def can_be_rendered?
  true
end

#cellObject



9
10
11
# File 'app/models/guide/structure.rb', line 9

def cell
  nil
end

#formatsObject



17
18
19
# File 'app/models/guide/structure.rb', line 17

def formats
  [:html]
end

#javascriptsObject



25
26
27
# File 'app/models/guide/structure.rb', line 25

def javascripts
  Guide.configuration.default_javascripts_for_structures
end

#layout_css_classesObject



13
14
15
# File 'app/models/guide/structure.rb', line 13

def layout_css_classes
  {}
end

#layout_templatesObject



56
57
58
59
60
# File 'app/models/guide/structure.rb', line 56

def layout_templates
  {
    :html => default_layout_template
  }
end

#layout_view_modelObject



62
63
64
# File 'app/models/guide/structure.rb', line 62

def layout_view_model
  Guide::ViewModel.new
end

#partialObject



6
7
# File 'app/models/guide/structure.rb', line 6

def partial
end

#scenariosObject



45
46
47
48
49
50
51
52
53
54
# File 'app/models/guide/structure.rb', line 45

def scenarios
  @scenarios ||=
  scenario_definitions.each.with_object({}) do |(id, scenario_definition), scenario_hash|
    scenario_hash[id] = OpenStruct.new(
      :name => scenario_definition.name,
      :view_model => send(id),
      :options => scenario_definition.options,
    )
  end
end

#stylesheetsObject



21
22
23
# File 'app/models/guide/structure.rb', line 21

def stylesheets
  Guide.configuration.default_stylesheets_for_structures
end

#templateObject



2
3
4
# File 'app/models/guide/structure.rb', line 2

def template
  partial
end