Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
restrict importing methods and rename methods when include module.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
tasks
ChangeLog
README
Rakefile

README

= function_importer
writing explicitly need function for a module. and support rename.

== Example
  require 'rubygems'
  require 'function_importer'
  module Utils
    extend FunctionExporter
    
    def escape str
      "escaped_#{str}"
    end
  end

  module Foo
    Utils.export self, :escape

    def run
      p(escape('str')) #=> "escaped_str"
    end
  end

  # you can rename methods when argument is Hash.
  module Bar
    Utils.export self, :escape => :my_escape

    def run
      p(my_escape('str')) #=> "escaped_str"
    end
  end

  # or syntax suger.
  module Baz
    extend FunctionImporter
    import_function Utils, :escape

    def run
      p(escape('str')) #=> "escaped_str"
    end
  end

  # apply to class method.
  module Baz
    extend FunctionImporter
    import_module_function Utils, :escape

    def self.run
      p(escape('str')) #=> "escaped_str"
    end
  end

== Descripotin
restrict importing methods and rename methods when include module.

== SEE ALSO
+module-import+: I'm not like this module interface. (For example, pollute Kernel#import ).

== Copyright

Author:: Keiji, Yoshimi <walf443 at gmail.com>
License:: you can redistribute it and/or modify it under the same terms as Ruby itself.

Something went wrong with that request. Please try again.