Class: GQL::Registry
- Inherits:
-
Object
- Object
- GQL::Registry
- Extended by:
- ActiveSupport::PerThreadRegistry
- Defined in:
- lib/gql/registry.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
Instance Method Summary collapse
- #fetch(key, baseclass = Field) ⇒ Object (also: #[])
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
10 11 12 |
# File 'lib/gql/registry.rb', line 10 def initialize reset end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
8 9 10 |
# File 'lib/gql/registry.rb', line 8 def cache @cache end |
Instance Method Details
#fetch(key, baseclass = Field) ⇒ Object Also known as: []
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gql/registry.rb', line 18 def fetch(key, baseclass = Field) cache[key] || begin const, name = if key.instance_of? ::Class [key, key.name] else [key.constantize, key] end raise Errors::InvalidClass.new(const, baseclass) unless const <= baseclass cache.update name => const, const => const cache[key] end end |
#reset ⇒ Object
14 15 16 |
# File 'lib/gql/registry.rb', line 14 def reset @cache = {} end |