attr_protected 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.md +55 -0
  2. data/lib/attr_protected.rb +18 -0
  3. metadata +63 -0
@@ -0,0 +1,55 @@
1
+ attr-protected
2
+ ==============
3
+
4
+ Banishing the '@' symbol from my Ruby code, henceforth, by loading a gem.
5
+
6
+ ## Why does this exist?
7
+ Great question. Turns out doing
8
+
9
+ ```
10
+ @attribute = "something"
11
+ ```
12
+
13
+ is pretty weak-sauce stuff in Ruby. I'd rather call a method.
14
+
15
+ ```
16
+ self.attribute = "something"
17
+ ```
18
+
19
+ This way, if I have fat fingers and spell something wrong, the interpreter tells me. I never claimed to be that smart.
20
+
21
+ ## Installing
22
+
23
+ Just add
24
+ ```
25
+ gem 'attr_protected'
26
+ ```
27
+
28
+ to your Gemfile. Or
29
+
30
+ ```
31
+ gem install attr_protected
32
+ ```
33
+ if you aren't using Bundler.
34
+
35
+ ## Using
36
+
37
+ ### attr_protected
38
+
39
+ ```
40
+ class Example
41
+ attr_protected :name, :age
42
+ end
43
+ ```
44
+ This method gives you publically readable i-vars, internally read/writeable
45
+
46
+ ### attr_hidden
47
+ ```
48
+ class Example
49
+ attr_protected :name
50
+ attr_hidden :age
51
+ end
52
+ ```
53
+ This method gives you publically hidden i-vars, internally read/writeable
54
+
55
+ Enjoy
@@ -0,0 +1,18 @@
1
+ class Class
2
+ private
3
+
4
+ def attr_protected(*attrs)
5
+ public
6
+ attr_reader *attrs
7
+ protected
8
+ attr_writer *attrs
9
+ public
10
+ end
11
+
12
+ def attr_hidden(*attrs)
13
+ protected
14
+ attr_reader *attrs
15
+ attr_writer *attrs
16
+ public
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: attr_protected
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brian Pratt
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Provides a few methods to set up internal accessors for instance variables
31
+ email:
32
+ - brian@pratt.io
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/attr_protected.rb
38
+ - README.md
39
+ homepage:
40
+ licenses: []
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: 1.3.6
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 1.8.24
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: Tell those nasty '@' sigils to fudge off.
63
+ test_files: []