Sha256: 68a5fd70cf7a040cce8bf09fe7b476c014c04e29ffddc17a5d63d54d166c3cd1

Contents?: true

Size: 762 Bytes

Versions: 7

Compression:

Stored size: 762 Bytes

Contents

class Card
  class View
    # A "stub" is a placeholder for a card view. It can only be used in
    # situations where the card identifier, known options, and nest mode
    # comprise all the info needed to reproduce the view as intended
    module Stub
      def stub
        "<card-view>#{stub_json}</card-view>"
      end

      def stub_json
        JSON.generate stub_hash
      end

      def stub_hash
        {
          cast: card.cast,
          options: normalized_options,
          mode: format.mode
        }
      end

      def validate_stub
        return if foreign_normalized_options.empty?
        raise "INVALID STUB: #{card.name}/#{ok_view}" \
              " has foreign options: #{foreign_normalized_options}"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
card-1.91 lib/card/view/stub.rb
card-1.21.0 lib/card/view/stub.rb
card-1.20.4 lib/card/view/stub.rb
card-1.20.3 lib/card/view/stub.rb
card-1.20.2 lib/card/view/stub.rb
card-1.20.1 lib/card/view/stub.rb
card-1.20.0 lib/card/view/stub.rb