How to run examples:
- Run $ createdb nplusonedb to create DB
- Run specs $ rspec demo.rb
| # official docs: https://graphql-ruby.org/dataloader/sources.html | |
| # app/graphql/sources/association.rb | |
| class Sources::Association < ::GraphQL::Dataloader::Source | |
| def initialize(association_name, scope = nil) | |
| @association_name = association_name | |
| @scope = scope | |
| end | |
| def fetch(records) |
How to run examples:
| # | |
| # Show how to implement Java-like method annotations in Ruby. This example shows how to create | |
| # something more like Ruby's own private and public annotations, where each method that's declared | |
| # afterwards has its visibility set to private/public. | |
| # | |
| # To make this work more like a Java annotation (works for only one method), then you just have | |
| # to @_admin_only to nil in the "unless" condition from #method_added | |
| # | |
| # (source: http://www.diegocarrion.com/2010/05/27/ruby-annotations/) | |
| # |