discourse/plugins/automation/app/serializers/discourse_automation/template_serializer.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
926 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module DiscourseAutomation
class TemplateSerializer < ApplicationSerializer
attributes :name,
:component,
:extra,
:accepts_placeholders,
:accepted_contexts,
:read_only,
:default_value,
:is_required
def default_value
scope[:automation].scriptable&.forced_triggerable&.dig(:state, name) || object[:default_value]
end
def read_only
scope[:automation].scriptable&.forced_triggerable&.dig(:state, name).present?
end
def name
object[:name]
end
def component
object[:component]
end
def extra
object[:extra]
end
def accepts_placeholders
object[:accepts_placeholders]
end
def accepted_contexts
object[:accepted_contexts]
end
def is_required
object[:required]
end
end
end