class Playbook::Props::Base
def initialize(name:, kit:, default: nil, deprecated: false, required: false)
def initialize(name:, kit:, default: nil, deprecated: false, required: false) @default = default @deprecated = deprecated @required = required @name = name @kit = kit end
def log(message)
def log(message) logger = ActiveSupport::Logger.new($stdout) @logger ||= ActiveSupport::TaggedLogging.new(logger) @logger.log(0, message) end
def validate(_value)
def validate(_value) true end
def validate!(input_value)
def validate!(input_value) # warn("#{kit} Kit: The prop '#{name}' is deprecated and will be removed in a future release!") if deprecated && input_value # TODO: add some color for pop raise(Playbook::Props::Error, "#{kit} prop '#{name}' of type #{inspect.class} is required and needs a value") if required && input_value.nil? validate(value(input_value)) || raise(Playbook::Props::Error, "#{kit} has invalid value of '#{input_value.inspect}' for prop '#{name}' of type #{inspect.class}") end
def value(value)
def value(value) value.nil? ? @default : value end
def warn(message)
def warn(message) log("Prop Warning: #{message}") end