Skip to content
This repository was archived by the owner on Jan 8, 2023. It is now read-only.

maxim/kwstruct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Now that ruby structs have keyword_init: true, and Data class works with keywords out of the box, this is no longer needed. For a more featureful approach, consider portrayal.

kwstruct

Just like regular Struct, but uses keyword arguments.

Person = KwStruct.new(:name, :age)
sammy = Person.new(name: 'Sammy', age: 30)

Any non-existent arguments will raise an ArgumentError.

Installation

$ gem install kwstruct

Credits

Thanks @apeiros for ideas.
Thanks @bughit for hitting a bug.

About

Struct with keyword arguments support

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages