Module: Spree::Api::V2::ResourceSerializerConcern
- Extended by:
- ActiveSupport::Concern
- Included in:
- Platform::AddressSerializer, Platform::AdjustmentSerializer, Platform::AssetSerializer, Platform::CalculatorSerializer, Platform::ClassificationSerializer, Platform::CmsPageSerializer, Platform::CmsSectionSerializer, Platform::CountrySerializer, Platform::CreditCardSerializer, Platform::CustomerReturnSerializer, Platform::InventoryUnitSerializer, Platform::LineItemSerializer, Platform::LogEntrySerializer, Platform::MenuItemSerializer, Platform::MenuSerializer, Platform::OptionTypeSerializer, Platform::OptionValueSerializer, Platform::OrderPromotionSerializer, Platform::OrderSerializer, Platform::PaymentCaptureEventSerializer, Platform::PaymentSerializer, Platform::PriceSerializer, Platform::ProductPropertySerializer, Platform::ProductSerializer, Platform::PromotionActionLineItemSerializer, Platform::PromotionActionSerializer, Platform::PromotionCategorySerializer, Platform::PromotionRuleSerializer, Platform::PromotionSerializer, Platform::PropertySerializer, Platform::PrototypeSerializer, Platform::RefundReasonSerializer, Platform::RefundSerializer, Platform::ReimbursementSerializer, Platform::ReimbursementTypeSerializer, Platform::ReturnAuthorizationReasonSerializer, Platform::ReturnAuthorizationSerializer, Platform::ReturnItemSerializer, Platform::RoleSerializer, Platform::ShipmentSerializer, Platform::ShippingCategorySerializer, Platform::ShippingRateSerializer, Platform::StateChangeSerializer, Platform::StateSerializer, Platform::StockItemSerializer, Platform::StockLocationSerializer, Platform::StockMovementSerializer, Platform::StockTransferSerializer, Platform::StoreCreditCategorySerializer, Platform::StoreCreditEventSerializer, Platform::StoreCreditSerializer, Platform::StoreCreditTypeSerializer, Platform::StoreSerializer, Platform::TaxCategorySerializer, Platform::TaxRateSerializer, Platform::TaxonSerializer, Platform::TaxonomySerializer, Platform::VariantSerializer, Platform::Webhooks::EventSerializer, Platform::Webhooks::SubscriberSerializer, Platform::WishedItemSerializer, Platform::WishlistSerializer, Platform::ZoneMemberSerializer, Platform::ZoneSerializer
- Defined in:
- app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb
Class Method Summary collapse
Class Method Details
.display_getter_methods(model_klazz) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb', line 22 def self.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 method_name end end |
.included(base) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb', line 7 def self.included(base) serializer_base_name = base.to_s.sub(/^Spree::Api::V2::Platform::/, '').sub(/Serializer$/, '') model_klazz = "Spree::#{serializer_base_name}".constantize base.set_type model_klazz.json_api_type # include standard attributes base.attributes(*model_klazz.json_api_columns) # include money attributes display_getter_methods(model_klazz).each do |method_name| base.attribute(method_name) do |object| object.public_send(method_name).to_s end end end |