Class: Raw::ATOMFormat

Inherits:
Format
  • Object
show all
Defined in:
lib/raw/dispatcher/format/atom.rb

Instance Attribute Summary

Attributes inherited from Format

#content_type, #extension, #name, #template_extension

Instance Method Summary collapse

Methods inherited from Format

#before_action, #filter_template, #to_s

Constructor Details

#initializeATOMFormat

Returns a new instance of ATOMFormat.



9
10
11
12
13
14
# File 'lib/raw/dispatcher/format/atom.rb', line 9

def initialize
  @name = "atom"
  @content_type = "application/atom+xml" # "text/xml"
  @extension = "atom"
  @template_extension = "atomx"
end

Instance Method Details

#after_action(controller, context) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/raw/dispatcher/format/atom.rb', line 16

def after_action(controller, context)
  if controller.out.blank?
    if model = controller.class.ann(:self, :model)
      resource = model.to_s.demodulize.underscore
      if collection = controller.instance_variable_get("@#{resource.plural}")
        controller.send(:print, XOXO.dump(collection))
      elsif resource = controller.instance_variable_get("@#{resource}") 
        controller.send(:print, XOXO.dump(resource))
      end
    end
  end
end