Class: Cybertrain::Component

Inherits:
Object
  • Object
show all
Defined in:
cybertrain/component.rb,
cybertrain/template/interpreter.rb

Direct Known Subclasses

CommentComponent, ComponentCollection

Defined Under Namespace

Classes: Unknown

Instance Method Summary collapse

Instance Method Details

#call_view_method(name) ⇒ Object

A parameterless public method, by name (gen/components.rb); nil here.



46
47
48
# File 'cybertrain/component.rb', line 46

def call_view_method(name)
  nil
end

#component_name ⇒ Object

“card” for CardComponent, “admin/user_row” for Admin::UserRowComponent: the name render component: uses. gen/components.rb spells it out per class (under Spinel Class#name has no namespace, rule 46).



60
61
62
# File 'cybertrain/component.rb', line 60

def component_name
  Component.name_for(self.class.name)
end

#content ⇒ Object

The block a template passed (render component: "card" do ... end), “” when there was none. Subclasses do not call super in initialize, so it may never have been assigned.



74
75
76
77
78
79
# File 'cybertrain/component.rb', line 74

def content
  c = @content
  return SafeString.of("") if c.nil?

  c
end

#content=(html) ⇒ Object



82
83
84
# File 'cybertrain/component.rb', line 82

def content=(html)
  @content = SafeString.of(html.to_s)
end

#view_assigns ⇒ Object

The instance variables the template reads, by name. Typed empty Hash of polymorphic values (spikes/NOTES.md rules 9, 71); gen/components.rb overrides it.



38
39
40
41
42
# File 'cybertrain/component.rb', line 38

def view_assigns
  out = { "" => [nil, 0, 0.0, "", true][0] }
  out.delete("")
  out
end