Sha256: 4567753536057cbbdf5bc3d3e6f6f334470d2de7fffff2c4a09e8c55156383af

Contents?: true

Size: 1.2 KB

Versions: 15

Compression:

Stored size: 1.2 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(Card::View::Stub.unescape @options_json).symbolize_keys
          interpret_hash_values
        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_view_opts
          @stub_hash[:view_opts].symbolize_keys!
        end

        def interpret_format_opts
          hash = @stub_hash[:format_opts]
          hash.symbolize_keys!
          hash[:nest_mode] = hash[:nest_mode].to_sym
          hash[:override] = hash[:override] == "true"
        end

        def process_chunk
          @processed = yield @stub_hash
        end

        def result
          @processed
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
card-1.97.0.1 mod/core/chunk/view_stub.rb
card-1.97.0 mod/core/chunk/view_stub.rb
card-1.96.8 mod/core/chunk/view_stub.rb
card-1.96.7 mod/core/chunk/view_stub.rb
card-1.96.6 mod/core/chunk/view_stub.rb
card-1.96.5 mod/core/chunk/view_stub.rb
card-1.96.4 mod/core/chunk/view_stub.rb
card-1.96.3 mod/core/chunk/view_stub.rb
card-1.96.2 mod/core/chunk/view_stub.rb
card-1.96.1 mod/core/chunk/view_stub.rb
card-1.96.0 mod/core/chunk/view_stub.rb
card-1.95.3 mod/core/chunk/view_stub.rb
card-1.95.2 mod/core/chunk/view_stub.rb
card-1.95.1 mod/core/chunk/view_stub.rb
card-1.95.0 mod/core/chunk/view_stub.rb