Class: Mime::Component
- Inherits:
-
Object
- Object
- Mime::Component
- Defined in:
- lib/mime-components/components/components.rb
Overview
A component is a class with a ‘render’ function. This function’s output will replace the final XML in the rendered document.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.attr_true?(value) ⇒ True|False
Check if an attribute’s value is truthy.
Instance Method Summary collapse
-
#initialize(name, &proc) ⇒ Component
constructor
Create a new component.
-
#render(attributes, vars) ⇒ String
Call this component’s rendering function.
Constructor Details
#initialize(name, &proc) ⇒ Component
Create a new component.
21 22 23 24 |
# File 'lib/mime-components/components/components.rb', line 21 def initialize(name, &proc) @name = name @proc = proc end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
34 35 36 |
# File 'lib/mime-components/components/components.rb', line 34 def name @name end |
Class Method Details
.attr_true?(value) ⇒ True|False
Check if an attribute’s value is truthy.
14 15 16 |
# File 'lib/mime-components/components/components.rb', line 14 def self.attr_true?(value) [1, 'true', 'yes'].include?(value.to_s.strip.downcase) end |
Instance Method Details
#render(attributes, vars) ⇒ String
Call this component’s rendering function.
30 31 32 |
# File 'lib/mime-components/components/components.rb', line 30 def render(attributes, vars) @proc.call(attributes, vars) end |