Sha256: 7e73a002564cbdca378f1911e0a668d86d8cb54cf43c63ad61478d386519608f

Contents?: true

Size: 623 Bytes

Versions: 145

Compression:

Stored size: 623 Bytes

Contents

require "securerandom"

module Avo
  module Fields
    class HeadingField < BaseField
      attr_reader :as_html

      def initialize(id, **args, &block)
        args[:updatable] = false
        @label = args[:label] || id.to_s.humanize

        super(id, **args, &block)

        # this field is not used to update anything
        @for_presentation_only = true

        hide_on :index

        @as_html = args[:as_html].presence || false
      end

      def id
        "heading_#{name.to_s.parameterize.underscore}"
      end

      def value
        block.present? ? execute_block : @label
      end
    end
  end
end

Version data entries

145 entries across 145 versions & 1 rubygems

Version Path
avo-3.18.1.tw4 lib/avo/fields/heading_field.rb
avo-3.18.1 lib/avo/fields/heading_field.rb
avo-3.18.0.tw4 lib/avo/fields/heading_field.rb
avo-3.18.0 lib/avo/fields/heading_field.rb
avo-3.17.9.beta2 lib/avo/fields/heading_field.rb
avo-3.17.9.beta1 lib/avo/fields/heading_field.rb
avo-3.17.9.tw4 lib/avo/fields/heading_field.rb
avo-3.17.9 lib/avo/fields/heading_field.rb
avo-3.17.8.tw4 lib/avo/fields/heading_field.rb
avo-3.17.8 lib/avo/fields/heading_field.rb
avo-3.17.7 lib/avo/fields/heading_field.rb
avo-3.17.6.tw4 lib/avo/fields/heading_field.rb
avo-3.17.6 lib/avo/fields/heading_field.rb
avo-3.17.5 lib/avo/fields/heading_field.rb
avo-3.17.4 lib/avo/fields/heading_field.rb
avo-3.17.3 lib/avo/fields/heading_field.rb
avo-3.17.5.tw4 lib/avo/fields/heading_field.rb
avo-3.17.4.tw4 lib/avo/fields/heading_field.rb
avo-3.17.3.tw4 lib/avo/fields/heading_field.rb
avo-3.17.2.tw4 lib/avo/fields/heading_field.rb