attr_reader_cr
Version, currently 0.1.01 version
- 0.1.0latestOct 19, 2026
github.com/OrelSokolov/attr_reader.cr
ruby attr_reader aliases for crystal
0 stars
12 dependents
License: not declared
Installation
# Add this to your shard.yml
dependencies:
attr_reader_cr:
github: OrelSokolov/attr_reader.cr
version: ~> 0.1.0Then run:
shards installshard.yml
- Crystal
>= 1.21.0
Dependencies
This version declares no dependencies.
README
attr_reader.cr
Ruby-compat attr_reader / attr_writer / attr_accessor macros for
Crystal — Rails-style declarations with zero dependencies.
Extracted from
active_support.cr so
low-level shards can use Rails-style attribute declarations without pulling
in pg/redis transitively.
Usage
require "attr_reader_cr"
class User
attr_reader :body, :content_type # Ruby-style symbols
attr_accessor name : String = "anon" # typed declaration with default
attr_writer :secret # generates secret=
end
Mapping
| Ruby | idiomatic Crystal | attr_reader.cr |
|---|---|---|
attr_reader :foo | getter foo | attr_reader :foo |
attr_writer :foo | setter foo | attr_writer :foo |
attr_accessor :foo | property foo | attr_accessor :foo |
All forms delegate to the stdlib getter/setter/property macros, so
typed declarations and defaults pass straight through:
attr_accessor name : String = "anon", level : Int32 = 0
Installation
-
Add the dependency to
shard.yml:dependencies: attr_reader_cr: github: OrelSokolov/attr_reader.cr version: ~> 0.1.0 -
Run
shards install
License
MIT
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- Oct 19, 2026
- Commit
97e918fc892a- Crystal
>= 1.21.0- Indexed
- yes
Dependents
Repository
github.com/OrelSokolov/attr_reader.cr
Metadata
- Created
- Oct 20, 2026
- Updated
- Oct 25, 2026
- Synced
- Oct 25, 2026
- Versions
- 1