Permalink
Browse files

Rename export to friend (new name)

  • Loading branch information...
1 parent 7b5e19e commit ab74e2bc8bf7f4e346ee1a184b324b1e626a2ee3 @lsegal committed Apr 1, 2010
Showing with 13 additions and 13 deletions.
  1. +1 −1 examples/export_features.rb
  2. +1 −1 examples/friends.rb
  3. +10 −10 lib/{export.rb → friend.rb}
  4. +1 −1 test/export_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../lib/export'
+require File.dirname(__FILE__) + '/../lib/friend'
class A; def bar; D.new.foo end end
class B; def bar; D.new.foo end end
View
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../lib/export'
+require File.dirname(__FILE__) + '/../lib/friend'
class Car
def initialize; @engine = Engine.new end
@@ -1,30 +1,30 @@
require File.dirname(__FILE__) + '/../ext/callsite'
-module Export
- def export_list
- @__exported__ ||= {}
+module Friend
+ def friend_list
+ @__friends__ ||= {}
end
- def export(meth, *classes)
- meth, expmeth = meth.to_s, "__exported__#{meth}"
- (export_list[meth] ||= []).push(*classes)
+ def friend(meth, *classes)
+ meth, expmeth = meth.to_s, "__friends__#{meth}"
+ (friend_list[meth] ||= []).push(*classes)
alias_method expmeth, meth
private expmeth
public meth
define_method(meth) do |*args, &block|
- cclass, classes = caller_class, self.class.export_list[meth]
+ cclass, classes = caller_class, self.class.friend_list[meth]
if cclass == false
raise NoMethodError, "`#{meth}' is not accessible outside #{self.class}"
elsif cclass != self.class && classes && !classes.any? {|k| cclass <= k }
raise NoMethodError,
"`#{meth}' is not accessible to #{cclass.inspect}:#{cclass.class.inspect}",
caller
end
- send("__exported__#{meth}", *args, &block)
+ send(expmeth, *args, &block)
end
end
- alias friend export
+ alias export friend
end
-(RUBY_VERSION >= "1.9.1" ? BasicObject : Object).send(:extend, Export)
+(RUBY_VERSION >= "1.9.1" ? BasicObject : Object).send(:extend, Friend)
View
@@ -1,5 +1,5 @@
require "test/unit"
-require File.dirname(__FILE__) + '/../lib/export'
+require File.dirname(__FILE__) + '/../lib/friend'
class A; def bar; D.new.foo end end
class B; def bar; D.new.foo end end

0 comments on commit ab74e2b

Please sign in to comment.