Sha256: a92a23a3eb1f8c3ced701683ba19878680f5fb0883e81bcdefa224a58cfe620b

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

class Card
  class Content
    module Chunk
      class ViewStub < Abstract
        Chunk.register_class(
          self,
          prefix_re: Regexp.escape("(stub)"),
          full_re: /\(stub\)([^\(]*)\(\/stub\)/,
          idx_char: "("
        )

        def initialize text, content
          super
        end

        def interpret match, _content
          @options_json = match[1]
          @stub_hash = JSON.parse(unescape @options_json).symbolize_keys
          interpret_hash_values
        end

        def unescape stub_json
          stub_json.gsub '(', '_OParEN_'
        end

        def interpret_hash_values
          @stub_hash.keys.each do |key|
            send "interpret_#{key}"
          end
        end

        def interpret_cast
          @stub_hash[:cast].symbolize_keys!
        end

        def interpret_options
          @stub_hash[:options].symbolize_keys!
        end

        def interpret_mode
          @stub_hash[:mode] = @stub_hash[:mode].to_sym
        end

        def interpret_override
          @stub_hash[:override] = @stub_hash[:override] == "true"
        end

        def process_chunk
          @processed = yield @stub_hash
        end

        def result
          @processed
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
card-1.93.0 mod/core/chunk/view_stub.rb