Skip to content

Commit

Permalink
Add Reflection section to README.md
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Hollinger <[email protected]>
  • Loading branch information
jhollinger committed Jan 23, 2024
1 parent 81ae047 commit 12aeb95
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,35 @@ Output:

</details>

<details>
<summary>Reflection</summary>

Blueprint classes may be reflected on to inspect their views, fields, and associations.

```ruby
# A Hash of views keyed by name
views = WidgetBlueprint.reflections
views.keys
=> [:default, :extended]

# Hashes of fields and associations, keyed by name
fields = views[:default].fields
assoc = views[:default].associations

# Get info about a field
fields[:description].name
fields[:description].display_name
fields[:description].options

# Get info about an association
assoc[:category].name
assoc[:category].display_name
assoc[:category].blueprint
assoc[:category].view
assoc[:category].options
```
</details>

<details>
<summary>Deprecations</summary>

Expand Down

0 comments on commit 12aeb95

Please sign in to comment.