Class: GraphQL::Models::ActiveRecordExtension::EnumTypeHash

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/graphql/models/active_record_extension.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEnumTypeHash

Returns a new instance of EnumTypeHash.



11
12
13
# File 'lib/graphql/models/active_record_extension.rb', line 11

def initialize
  @hash = {}.with_indifferent_access
end

Instance Attribute Details

#hashObject

Returns the value of attribute hash.



9
10
11
# File 'lib/graphql/models/active_record_extension.rb', line 9

def hash
  @hash
end

Instance Method Details

#[](attribute) ⇒ Object



15
16
17
18
19
20
# File 'lib/graphql/models/active_record_extension.rb', line 15

def [](attribute)
  type = hash[attribute]
  type = type.call if type.is_a?(Proc)
  type = type.constantize if type.is_a?(String)
  type
end