Module: SpreeCmCommissioner::Api::V2::ResourceSerializerConcernDecorator

Defined in:
app/serializers/concerns/spree_cm_commissioner/api/v2/resource_serializer_concern_decorator.rb

Class Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/serializers/concerns/spree_cm_commissioner/api/v2/resource_serializer_concern_decorator.rb', line 5

def self.prepended(base)
  def base.display_getter_methods(model_klazz)
    model_klazz.new.methods.find_all do |method_name|
      next unless method_name.to_s.start_with?('display_')
      next if method_name.to_s.end_with?('=')
      next if [Spree::Product, Spree::Variant].include?(model_klazz) && method_name == :display_amount

      # commissioner:
      # Skip 'display_vendor_' to not dynamic load 'display_vendor_' methods as attributes.
      #
      # In spree_multi_vendor, 'display_vendor_..' methods required :vendor args
      # while default attributes of spree_api does not provide that which cause error when serialize for PlatformApis & Webhook
      next if method_name.to_s.start_with?('display_vendor')

      method_name
    end
  end
end