Method: Fabulator::TagLib::ClassMethods#action

Defined in:
lib/fabulator/tag_lib.rb

#action(name, klass = nil, &block) ⇒ Object



344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/fabulator/tag_lib.rb', line 344

def action(name, klass = nil, &block)
  self.action_descriptions[name.to_sym] = Fabulator::TagLib.last_description if Fabulator::TagLib.last_description
  Fabulator::TagLib.last_description = nil
  if block
    define_method("action:#{name.to_s}", block)
  elsif !klass.nil?
    Fabulator::TagLib.structural_classes[self.name] ||= {}
    Fabulator::TagLib.structural_classes[self.name][name.to_sym] = klass
    action(name) { |e,c|
      r = klass.new
      r.compile_xml(e,c)
      r
    }
  end
end