Class: Vapid::Directive
- Includes:
- Padrino::Helpers::TagHelpers
- Defined in:
- lib/vapid/directive.rb
Overview
Base class for directives
Direct Known Subclasses
Vapid::Directives::Audio, Vapid::Directives::Date, Vapid::Directives::Group, Vapid::Directives::Hide, Vapid::Directives::Href, Vapid::Directives::Image, Vapid::Directives::Richtext, Vapid::Directives::Show, Vapid::Directives::Text, Vapid::Directives::Video
Instance Attribute Summary collapse
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Class Method Summary collapse
-
.destroyable? ⇒ Boolean
Whether the directive can be destroyed (usually via a checkbox).
-
.modifies_content? ⇒ Boolean
Whether the directive writes content to the database.
-
.previewable? ⇒ Boolean
Whether the directive previews the content.
-
.serialize_input(input) ⇒ String
Serializes input before it’s saved to the database.
Instance Method Summary collapse
-
#initialize(expression) ⇒ Directive
constructor
A new instance of Directive.
-
#render(input = nil) ⇒ Object
Renders content.
Constructor Details
#initialize(expression) ⇒ Directive
Returns a new instance of Directive.
107 108 109 |
# File 'lib/vapid/directive.rb', line 107 def initialize(expression) parse_expression(expression) end |
Instance Attribute Details
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
13 14 15 |
# File 'lib/vapid/directive.rb', line 13 def subject @subject end |
Class Method Details
.destroyable? ⇒ Boolean
Whether the directive can be destroyed (usually via a checkbox).
38 39 40 |
# File 'lib/vapid/directive.rb', line 38 def destroyable? destroy end |
.modifies_content? ⇒ Boolean
Whether the directive writes content to the database.
24 25 26 |
# File 'lib/vapid/directive.rb', line 24 def modifies_content? respond_to?(:form_field) end |
.previewable? ⇒ Boolean
Whether the directive previews the content.
31 32 33 |
# File 'lib/vapid/directive.rb', line 31 def previewable? preview end |
.serialize_input(input) ⇒ String
Serializes input before it’s saved to the database
45 46 47 |
# File 'lib/vapid/directive.rb', line 45 def serialize_input(input) input.to_s end |
Instance Method Details
#render(input = nil) ⇒ Object
Renders content
115 116 117 118 119 |
# File 'lib/vapid/directive.rb', line 115 def render(input = nil) @input = deserialize_input(input) apply_filters render_all end |