Method: GraphQL::Schema::Directive::Flagged#initialize
- Defined in:
- lib/graphql/schema/directive/flagged.rb
#initialize(target, **options) ⇒ Flagged
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/graphql/schema/directive/flagged.rb', line 9 def initialize(target, **) if target.is_a?(Module) && !target.ancestors.include?(VisibleByFlag) # This is type class of some kind, `include` will put this module # in between the type class itself and its super class, so `super` will work fine target.include(VisibleByFlag) elsif !target.is_a?(VisibleByFlag) # This is an instance of a base class. `include` won't put this in front of the # base class implementation, so we need to `.prepend`. # `#visible?` could probably be moved to a module and then this could use `include` instead. target.class.prepend(VisibleByFlag) end super end |