Class: Adva::Markup

Inherits:
Rails::Engine
  • Object
show all
Includes:
Engine
Defined in:
lib/adva/markup.rb,
lib/adva/markup/active_record.rb,
lib/adva/markup/action_controller.rb

Defined Under Namespace

Modules: ActionController, ActiveRecord

Class Method Summary collapse

Class Method Details

.apply(name, markup) ⇒ Object



21
22
23
24
25
# File 'lib/adva/markup.rb', line 21

def apply(name, markup)
  if filter = self.filter(name)
    filter.new(markup).to_html
  end
end

.filter(name) ⇒ Object



27
28
29
# File 'lib/adva/markup.rb', line 27

def filter(name)
  filters[name.to_sym].constantize if name.present? && filters[name.to_sym]
end

.keysObject



31
32
33
# File 'lib/adva/markup.rb', line 31

def keys
  @keys ||= filters.keys.map(&:to_s).sort
end

.namesObject



35
36
37
# File 'lib/adva/markup.rb', line 35

def names
  @names ||= keys.map { |key| key.titleize }
end

.optionsObject



39
40
41
# File 'lib/adva/markup.rb', line 39

def options
  @options ||= Hash[*names.zip(keys).flatten]
end