Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

modify namescope

  • Loading branch information...
commit 1e04ad08048e2bceb3e6b7c13f09deb351c74943 1 parent 19899f1
Kenichi Kamiya authored
Showing with 17 additions and 15 deletions.
  1. +17 −15 lib/instancevalue.rb
32 lib/instancevalue.rb
View
@@ -22,7 +22,7 @@
# person.age #=> age at runtime
# person.instance_eval{val :birthday, Time.now} #=> Exception
module InstanceValue
- VERSION = '0.0.1'.freeze
+ VERSION = '0.0.2'.freeze
module Eigen
private
@@ -42,20 +42,6 @@ def included(mod)
end
end
- # @example
- # val(name) #=> get
- # val(name, const_value) #=> set
- def val(name, *values)
- case values.length
- when 0
- instance_value_get name
- when 1
- instance_value_set name, values.first
- else
- raise ArgumentError, "wrong number of Argument #{values.length} for 1 or 2"
- end
- end
-
def instance_value_defined?(name)
unless name.instance_of?(Symbol) or name.respond_to?(:to_str)
raise TypeError
@@ -85,6 +71,8 @@ def instance_values
singleton_class::VALUES.keys
end
+ private
+
def remove_instance_value(name)
if instance_value_defined? name
singleton_class::VALUES.delete_key name.to_sym
@@ -92,4 +80,18 @@ def remove_instance_value(name)
raise NameError
end
end
+
+ # @example
+ # val(name) #=> get
+ # val(name, const_value) #=> set
+ def val(name, *values)
+ case values.length
+ when 0
+ instance_value_get name
+ when 1
+ instance_value_set name, values.first
+ else
+ raise ArgumentError, "wrong number of Argument #{values.length} for 1 or 2"
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.