class PostSerializer < ActiveModel::Serializer
attributes :id, :title, :excerpt, :body, :published_at, :views, :likes_count, :comments_count
attribute :can_edit, if: :current_user_can_edit?
belongs_to :author, serializer: UserSummarySerializer
class PostsController < ApplicationController
def index
posts = Post.for_feed.page(params[:page]).per(25)
render json: {
data: posts.map { |post| PostSerializer.new(post).as_json },
class NotifyFollowersJob
include Sidekiq::Job
sidekiq_options queue: :notifications, retry: 5
def perform(post_id, actor_id)
class ProjectPresenter
def initialize(project, include_tasks: true)
@project = project
@include_tasks = include_tasks
end
class OrderPresenter < SimpleDelegator
attr_reader :current_user
def initialize(order, current_user:)
super(order)
@current_user = current_user
module DefensiveDeserialization
extend ActiveSupport::Concern
MissingRecord = Struct.new(:gid) do
def missing?
true
module Notifications
class RecipientSerializer < ActiveJob::Serializers::ObjectSerializer
def serialize?(argument)
argument.is_a?(Notifications::Recipient)
end
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct Config {
host: String,
port: u16,
module Api
module V1
class UsersController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
before_action :set_user, only: [:show, :update, :destroy]
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
class User < ApplicationRecord
normalizes :phone, with: ->(value) { PhoneNormalizer.call(value) }, apply_to_nil: false
validates :phone,
presence: true,
uniqueness: { case_sensitive: false },