https://github.com/maxpleaner/auto_initializer
Automatically accept #initialize args for attr_reader properties
https://github.com/maxpleaner/auto_initializer
Last synced: 11 months ago
JSON representation
Automatically accept #initialize args for attr_reader properties
- Host: GitHub
- URL: https://github.com/maxpleaner/auto_initializer
- Owner: MaxPleaner
- Created: 2016-12-31T02:53:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-31T02:58:24.000Z (over 9 years ago)
- Last Synced: 2025-06-14T19:11:00.687Z (12 months ago)
- Language: Ruby
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
AutoInitializer
```sh
gem install auto_initializer
```
```rb
require 'auto_initializer'
class Test
attr_reader :foo
include AutoInitializer
end
(Test.new foo: :ok).foo
# => :ok
```
In simple english:
> If you were going to write an initializer for the sole purpose of passing arguments to
instance varaibles, there's no need. With this gem, you can have this happen automatically
(the initializer will accept any keyword arguments passed). You still need to write
attr_reader, attr_writer, etc. to read the data unless you use instance_variable_get.