Module: FastSerializer::Schema::Mixin::ClassMethods

Defined in:
lib/fast_serializer/schema/mixin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/fast_serializer/schema/mixin.rb', line 13

def method_missing(method, *args, &block)
  if __schema__.respond_to?(method)
    __schema__.public_send(method, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#__patched__Object

Returns the value of attribute __patched__.



7
8
9
# File 'lib/fast_serializer/schema/mixin.rb', line 7

def __patched__
  @__patched__
end

#__schema__Object

Returns the value of attribute __schema__.



7
8
9
# File 'lib/fast_serializer/schema/mixin.rb', line 7

def __schema__
  @__schema__
end

Instance Method Details

#__patch_with_attribute_definitionObject



25
26
27
28
29
30
31
# File 'lib/fast_serializer/schema/mixin.rb', line 25

def __patch_with_attribute_definition
  injectable_attributes = __schema__.serialization_schema.attributes.select { |_key, attribute| attribute.injectable? }
  injectable_attributes.each { |_, attribute| attribute.inject(self) }
  self.__patched__ = true

  __patched__.freeze
end

#inherited(subclass) ⇒ Object



9
10
11
# File 'lib/fast_serializer/schema/mixin.rb', line 9

def inherited(subclass)
  subclass.__schema__ = __schema__.deep_copy
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/fast_serializer/schema/mixin.rb', line 21

def respond_to_missing?(method_name, include_private = false)
  __schema__.respond_to?(method_name) || super
end