Module: RestfulX::ActionController

Defined in:
lib/restfulx/rx_action_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
7
# File 'lib/restfulx/rx_action_controller.rb', line 2

def self.included(base)
  base.class_eval do
    alias_method_chain :render, :amf
    alias_method_chain :render, :fxml
  end
end

Instance Method Details

#render_with_amf(options = nil, extra_options = {}, &block) ⇒ Object

Defines support for rendering :amf blocks from within Rails constrollers



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/restfulx/rx_action_controller.rb', line 10

def render_with_amf(options=nil, extra_options={}, &block)
  if Hash === options and options.key?(:amf)
    object = options.delete(:amf)
    unless String === object
      object = object.to_amf(options, &block) if object.respond_to?(:to_amf)
    end
    render_without_amf(:text => object, :content_type => RestfulX::Types::APPLICATION_AMF)
  else
    render_without_amf(options, extra_options, &block)
  end
end

#render_with_fxml(options = nil, extra_options = {}, &block) ⇒ Object

Defines support for rendering :fxml blocks from within Rails controllers



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/restfulx/rx_action_controller.rb', line 23

def render_with_fxml(options=nil, extra_options={}, &block)
  if Hash === options and options.key?(:fxml)
    object = options.delete(:fxml)
    unless String === object
      object = object.to_fxml(options, &block) if object.respond_to?(:to_fxml)
    end
    render_without_fxml(:text => object, :content_type => RestfulX::Types::APPLICATION_FXML)
  else
    render_without_fxml(options, extra_options, &block)
  end
end