Sha256: f6a77b7fbb42616f64f88848b6ce756c339b9ebf29171ac0c0365fe37f1adbf4

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

module RestfulX::ActionController
  def self.included(base)
    base.class_eval do
      alias_method_chain :render, :amf
      alias_method_chain :render, :fxml
    end
  end
  
  # Defines support for rendering :amf blocks from within Rails constrollers
  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
  
  # Defines support for rendering :fxml blocks from within Rails controllers
  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
restfulx-1.3.1 lib/restfulx/rx_action_controller.rb
restfulx-1.3.0 lib/restfulx/rx_action_controller.rb