diff options
| author | Teddy Wing | 2017-09-19 17:58:08 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-09-19 17:58:08 +0200 |
| commit | c9a997f337c9b45f62b50629de96fa95f20c1a7f (patch) | |
| tree | ce87b8ce2cf3bde2be68a36461059a4a37ba2580 /spec/lib/model_attribute_spec.rb | |
| parent | e1547b52a372942b34cda3b3fee4ab76e9f1b65e (diff) | |
| download | chouette-core-c9a997f337c9b45f62b50629de96fa95f20c1a7f.tar.bz2 | |
ModelAttribute: Make `@@all` a class instance variable
Robert argues that the class variable is not ideal because its value
gets shared with subclasses, violating the Liskov substitution
principle:
17:44:23 < robert> ```133] pry(main)> class A; @@greeting = :hello end
17:44:23 < robert> => :hello
17:44:23 < robert> [134] pry(main)> class B < A; end
17:44:23 < robert> => nil
17:44:23 < robert> [135] pry(main)> B.class_variable_get '@@greeting'
17:44:23 < robert> => :hello
Instead, go with his suggestion to use a class instance variable
instead, which gives us the same amount of availability of the `all`
list while not sharing it indiscriminately and making it easier to test.
Refs #4401
Diffstat (limited to 'spec/lib/model_attribute_spec.rb')
0 files changed, 0 insertions, 0 deletions
