Skip to content

Auto-generate Ruby methods from arel expressions - #10

Open
kbrock wants to merge 1 commit into
masterfrom
arel_ruby
Open

Auto-generate Ruby methods from arel expressions#10
kbrock wants to merge 1 commit into
masterfrom
arel_ruby

Conversation

@kbrock

@kbrock kbrock commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Add ruby: keyword to arel_attribute:

  • ruby: true — derive the Ruby method from the arel AST
  • ruby: "..." — use the given Ruby expression as the method body
  • ruby: nil — skip (default, backwards compatible)

ArelRuby.convert walks arel nodes (NamedFunction, math ops, CASE,
comparisons, grouping, literals) and emits Ruby source. The generated
methods are batched into a single module via module_eval and included
when Rails' define_attribute_methods fires.

Add `ruby:` keyword to `arel_attribute`:
- `ruby: true`   — derive the Ruby method from the arel AST
- `ruby: "..."`  — use the given Ruby expression as the method body
- `ruby: nil`    — skip (default, backwards compatible)

ArelRuby.convert walks arel nodes (NamedFunction, math ops, CASE,
comparisons, grouping, literals) and emits Ruby source. The generated
methods are batched into a single module via module_eval and included
when Rails' define_attribute_methods fires.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant