Sha256: 444cb2c62b35f38d4b89f54c19a429938cca26ba251e4b2d1f752bbdcc5d4af0

Contents?: true

Size: 352 Bytes

Versions: 2

Compression:

Stored size: 352 Bytes

Contents

module Juscribe # :nodoc:
  module DisplayOptional
    extend ActiveSupport::Concern

    included do
      class_attribute :unknown_label
      self.unknown_label = 'unnamed'
    end

    def to_s
      display_optional(to_param)
    end

    private
    def display_optional(value)
      value.blank? ? "(#{unknown_label})" : value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
personhood-0.2.0 lib/juscribe/display_optional.rb
personhood-0.1.2 lib/juscribe/display_optional.rb