This repository has been archived by the owner on May 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
59 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--readme README.md --private lib/**/*.rb - LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
README.rdoc | ||
README.md | ||
LICENSE | ||
History.rdoc | ||
History.md | ||
Manifest.txt | ||
Rakefile | ||
Gemfile | ||
struct-alias_member.gemspec | ||
|
||
lib/struct/alias_member.rb | ||
lib/struct/alias_member/version.rb | ||
lib/struct/alias_member/classmethods.rb | ||
lib/struct/alias_member/instancemethods.rb | ||
lib/struct/alias_member/core_ext.rb | ||
dspec/basic.rb | ||
example/basic.rb | ||
|
||
test/test_basic.rb | ||
|
||
example/README.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,3 @@ task default: [:test] | |
Rake::TestTask.new do |tt| | ||
tt.verbose = true | ||
end | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,37 @@ | ||
# Copyright (C) 2012 Kenichi Kamiya | ||
|
||
class Struct; module Alias_Member | ||
|
||
module ClassMethods | ||
|
||
# @return [Array<Symbol>] | ||
# @return [Hash] aliasA => autonymX, aliasB => autonymY | ||
def aliases | ||
@aliases.dup | ||
end | ||
|
||
# @param [Symbol, String] name | ||
# @param [Symbol, String, #to_sym] name | ||
# @return [Symbol] | ||
def autonym(name) | ||
name = name.to_sym | ||
|
||
members.include?(name) ? name : @aliases.fetch(name) | ||
end | ||
|
||
# @param [Symbol, String] aliased | ||
# @param [Symbol, String] source | ||
# @param [Symbol, String, #to_sym] aliased | ||
# @param [Symbol, String, #to_sym] autonym | ||
# @return [Module] | ||
def alias_member(aliased, source) | ||
def alias_member(aliased, autonym) | ||
class_eval do | ||
aliased, source = aliased.to_sym, source.to_sym | ||
aliased, autonym = aliased.to_sym, autonym.to_sym | ||
if @aliases.has_key?(aliased) or members.include?(aliased) | ||
raise Alias_Member::ArleadyDefinedError | ||
end | ||
|
||
@aliases[aliased] = source | ||
@aliases[aliased] = autonym | ||
|
||
alias_method aliased, source | ||
alias_method :"#{aliased}=", :"#{source}=" | ||
alias_method aliased, autonym | ||
alias_method :"#{aliased}=", :"#{autonym}=" | ||
end | ||
end | ||
|
||
end | ||
|
||
end; end | ||
end; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ class Struct | |
|
||
module Alias_Member | ||
|
||
VERSION = '0.0.1.1'.freeze | ||
VERSION = '0.0.2.a'.freeze | ||
|
||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters