Class: Para::AttributeField::Redactor

Inherits:
Base
  • Object
show all
Includes:
ActionView::Helpers::SanitizeHelper, ActionView::Helpers::TextHelper
Defined in:
lib/para/attribute_field/redactor.rb

Instance Attribute Summary

Attributes inherited from Base

#field_method, #field_type, #model, #name, #options, #type

Instance Method Summary collapse

Methods inherited from Base

#attribute_column_path, #determine_name_and_field_method!, #excerptable_value?, #field_name, field_option, #field_options, field_types, #parse_input, register, #searchable?, #type?

Constructor Details

#initialize(model, options = {}) ⇒ Redactor

Returns a new instance of Redactor.



9
10
11
12
# File 'lib/para/attribute_field/redactor.rb', line 9

def initialize(model, options = {})
  options.reverse_merge!(type: 'text', field_type: 'redactor')
  super(model, options)
end

Instance Method Details

#value_for(instance) ⇒ Object



14
15
16
17
18
19
# File 'lib/para/attribute_field/redactor.rb', line 14

def value_for(instance)
  (value = instance.send(name)) && truncate(
    sanitize(value, tags: []),
    length: 50
  )
end