Top > 開発ガイド > Rails Plugins > active_arguments

active_arguments

対象バージョン

当ドキュメントはactive_arguments-0.2.0向けです。

概要

メソッドの引数の受取を柔軟に行うためのライブラリです。

動作確認環境

  • Rails-2.1.0
  • Rails-1.2.6

ダウンロード

利用方法

 * flex(args)
   Arrayのインスタンスメソッド

  ex)
    def sample_method(*args)
      options = args.flex :controller, :action, :id
      p options
    end

    > sample_method('/sample/index', 'update', 1, {:params => {:name => 'hoge'}})
      => {:controller => '/sample/index', :action => 'update', :id => 1, :params => {:name => 'hoge'}}

    > sample_method(:controller => '/sample/index', :action => 'update', :id => 1, :params => {:name => 'hoge'})
      => {:controller => '/sample/index', :action => 'update', :id => 1, :params => {:name => 'hoge'}}