class Lookbook::InspectorTargetEntity
def display_options
def display_options DataObject.new(*scenarios.map(&:display_options)) end
def display_options? = display_options.any?
def display_options? = display_options.any?
def hidden?
def hidden? return true if @hidden scenarios.one? ? scenarios.first.hidden? : super end
def id
def id @id ||= Utils.id(name) end
def initialize(name, preview_entity, scenarios, default_priority: nil, hidden: nil)
def initialize(name, preview_entity, scenarios, default_priority: nil, hidden: nil) @name = Utils.name(name) @preview_entity = preview_entity @scenarios = scenarios @default_priority = default_priority @hidden = hidden @rendered_scenarios = {} @type = :target end
def label
def label scenarios.one? ? scenarios.first.label : super end
def lookup_path
def lookup_path "#{preview_entity.lookup_path}/#{name}" end
def mailer_preview?
def mailer_preview? scenarios.first&.mailer_preview? end
def notes?
def notes? scenarios.find { _1.notes? } end
def params
def params scenarios.flat_map(&:params).uniq(&:name) end
def params? = params.any?
def params? = params.any?
def parent = preview
def parent = preview
def preview = preview_entity
def preview = preview_entity
def preview_path(params = {})
def preview_path(params = {}) preview_target_path(preview_entity, self, params) end
def preview_template
def preview_template scenarios.first&.mailer_preview? ? Lookbook.config.inspector_target_mailer_template : Lookbook.config.inspector_target_preview_template end
def priority
def priority return @default_priority unless @default_priority.nil? scenarios.one? ? scenarios.first.priority : super end
def render_scenarios
def render_scenarios scenarios.each do |scenario| @rendered_scenarios[scenario.name.to_sym] = yield(scenario) end end
def scenarios_with_notes
def scenarios_with_notes if block_given? scenarios.each do |scenario| yield(scenario, scenario.notes) if scenario.notes? end else scenarios.select { _1.notes? } end end
def scenarios_with_output
def scenarios_with_output if block_given? scenarios.each do |scenario| yield(scenario, @rendered_scenarios[scenario.name.to_sym]) end else scenarios end end
def source_language
def source_language scenarios.first&.source_language end
def to_h
def to_h { entity: "inspector_target", id: id, uuid: uuid, name: name, label: label, hidden: hidden?, lookup_path: lookup_path, url_path: url_path, scenarios: scenarios.map(&:to_h) } end
def url_path
def url_path inspect_target_path(preview_entity, self) end
def uuid
def uuid @uuid ||= begin unique_id = Utils.id(preview.id, scenarios.one? ? scenarios.first.id : id) Utils.hash("#{type}#{unique_id}") end end