Sha256: 78a6c6649cc84b0fcd8103a217d29fde06e054270c65dd486aa68cc09296aed9

Contents?: true

Size: 576 Bytes

Versions: 1

Compression:

Stored size: 576 Bytes

Contents

# frozen_string_literal: true

module Halbuilder::Zoom
  TRUTHY = [true, "true", "TRUE", 1, "1"]
  FALSEY = [false, "false", "FALSE", 0, "0"]

  def hal_zoomed?(rel, default_setting)
    if default_setting.nil?
      true
    elsif zoom_param.nil?
      default_setting
    elsif TRUTHY.include?(zoom_param)
      true
    elsif FALSEY.include?(zoom_param)
      false
    else
      zoom_rels.include?(rel)
    end
  end

  private

  def zoom_param
    @context.params[:zoom]
  end

  def zoom_rels
    zoom_param.is_a?(Array) ? zoom_param : zoom_param.split(",")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
halbuilder-0.1.0 lib/halbuilder/zoom.rb