classprop 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/lib/classprop.rb +2 -13
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97ebdc34c9de6444609a82b228cc26cef04e7ca4e0c062d6786b2d919c9ed2f3
4
- data.tar.gz: 30ef0193b6f77837fa86a0444c597eb82976b469a8837bbd4b8d43069a05e6ab
3
+ metadata.gz: 1190b0042541c7422fdfcf7891769705395f1339fce8a59e87b663f908a93742
4
+ data.tar.gz: 9da99d32afe6924ed861cd64f9a3cc6bb3a49029bbea2a45bb35af8006abcfe5
5
5
  SHA512:
6
- metadata.gz: cf4fd42454b349e131394d1c13cf1ef10856106345a07a29e2f0317099990aee672b8bfd1b8d7f6668517c94e6ea536ac5cfd8eeec92964c205a71dbe07c0b0c
7
- data.tar.gz: 54c19c2c4ba81023250118f75a1f5d6723ccc8910dc832999a993fc38b895f8db7266aca0bcfee8f1cbea0af4d87a1546dd7d2071bbcb471c9db849a04251f05
6
+ metadata.gz: ae2533a97d7e3ac3f30d9706acf6f873dab107f75dadf0cd9ee1ba509ee6d8155a30f55f0f65b70af884204cc70387d165b3777c69b2335f1b99ad1587b0fc33
7
+ data.tar.gz: 1e7aa555f28167b94874b65167756f64920ceca0b291680b8a5ac9b8744ea36946b607e5f37c7b28cbb714b8de9b4ab5e4571548663c11ba85252e78d7f8babd
data/README.md CHANGED
@@ -9,7 +9,7 @@ called `fco`. Finally, it sets the value of that property to *base*.
9
9
  class Base
10
10
  include ClassProp
11
11
  define_class_prop 'fco'
12
- @fco = 'base'
12
+ self.fco = 'base'
13
13
  end
14
14
  ```
15
15
 
@@ -37,7 +37,7 @@ puts X1.fco # => 'base'
37
37
 
38
38
  ```ruby
39
39
  class X1
40
- @fco = 'x1'
40
+ self.fco = 'x1'
41
41
  end
42
42
  ```
43
43
 
@@ -66,7 +66,7 @@ that property then an error is raised when the property is retrieved.
66
66
  class Base
67
67
  include ClassProp
68
68
  define_class_prop 'fco'
69
- @fco = ClassProp::MustDefine
69
+ self.fco = ClassProp::MustDefine
70
70
  end
71
71
 
72
72
  class X1 < Base
@@ -90,4 +90,5 @@ mike@idocs.com
90
90
 
91
91
  | version | date | notes |
92
92
  |---------|--------------|-------------------------------|
93
- | 1.0 | Feb 24, 2020 | Initial upload. |
93
+ | 1.0 | Feb 24, 2020 | Initial upload. |
94
+ | 1.1 | Feb 24, 2020 | Reworked interface. |
@@ -2,8 +2,8 @@
2
2
  # ClassProp
3
3
  #
4
4
  module ClassProp
5
- # version 1.0
6
- VERSION = '1.0'
5
+ # version 1.1
6
+ VERSION = '1.1'
7
7
 
8
8
  # private
9
9
  private
@@ -43,17 +43,8 @@ module ClassProp
43
43
  # ClassMethods
44
44
  #
45
45
  module ClassMethods
46
- # Normalizes a property name so that any leading @ is removed.
47
- def normalize(prop_name)
48
- prop_name = prop_name.to_s
49
- prop_name = prop_name.sub(/\A\@/mu, '')
50
- return prop_name
51
- end
52
-
53
46
  # Defines the set and get methods for the given property.
54
47
  def define_class_prop(prop_name)
55
- prop_name = normalize(prop_name)
56
-
57
48
  # set
58
49
  self.define_singleton_method("#{prop_name}=") do |val|
59
50
  instance_variable_set "@#{prop_name}", val
@@ -81,8 +72,6 @@ module ClassProp
81
72
 
82
73
  # delete_class_prop
83
74
  def delete_class_prop(prop_name)
84
- prop_name = normalize(prop_name)
85
-
86
75
  if instance_variable_defined?("@#{prop_name}")
87
76
  remove_instance_variable "@#{prop_name}"
88
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classprop
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike O'Sullivan