An open API service indexing awesome lists of open source software.

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

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.