Giter VIP home page Giter VIP logo

rails3-amf's Introduction

Rails3-amf is a Rails 3 plugin that aims to do what RubyAMF did for Rails 2. It provides extensively customizable ActiveRecord serialization support, simple configuration, and allows AMF calls to any controller you choose. It uses RocketAMF for serialization, providing users with a proven AMF0/3 serializer and deserializer. Because of this, it’s also fully Ruby 1.9 compatible out of the box.

GETTING STARTED:

To get started with rails3-amf, all you need to do is add the following two lines to your gemfile. RocketAMF will need to be pulled from git for now, as there are several necessary updates that have been made to it to allow rails3-amf to work properly.

gem 'RocketAMF', :git => 'git://github.com/warhammerkid/rocket-amf.git'
gem 'rails3-amf', :git => 'git://github.com/warhammerkid/rails3-amf.git'

Then, make sure that your controller will respond to amf by adding :amf to your respond_to, and you should be all ready to go with an AMF gateway available at your-site.com/amf. ActiveRecord objects will automatically be serialized with all attributes and no relations, but that can be easilly adjusted through the standard serialization options for ActiveRecord and ActiveModel serialization.

class UserController < ApplicationController
  respond_to :html, :amf

  def getUser
    @user = User.first
    respond_with(@user) do |format|
      format.amf { render :amf => @user.to_amf(:except => [:updated_at, :created_at], :include => [:courses]) }
    end
  end
end

CONFIGURATION:

Rails3-amf has several configuration options. The gateway path, which defaults to “/amf” can be changed to anything you choose. You can map method call arguments by index to named params in your controllers. Finally, there’s the ability to specify flash->ruby class name mappings.

Example:

config.rails3amf.gateway_path = "/rubyamf/gateway"
config.rails3amf.class_mapping do |m|
  m.map :as => 'Test::User', :ruby => 'User'
  m.map :as => 'vo.Course', :ruby => 'Course'
end
config.rails3amf.map_params :controller => 'UserController', :action => 'getUser', :params => [:session_id]

LICENSE:

(The MIT License)

Copyright © 2010 Stephen Augenstein

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.