Sha256: 5addfe3008650a92cc6f263575320689fee04bb1166c6089334b6ddcbacdae3e

Contents?: true

Size: 672 Bytes

Versions: 1

Compression:

Stored size: 672 Bytes

Contents

module Metamagic
  class Tag
    attr_reader :context, :key, :value

    def initialize(context, key, value)
      @context, @key, @value = context, key.to_s, value
      @key = @key.gsub /^[^:]+:/, "" if remove_prefix?
    end

    def to_html
      raise "#{self.class.name}#to_html must be overridden to render tag"
    end

    def sort_order
      1000
    end

    def remove_prefix?
      true
    end

    def ==(other)
      self.class == other.class && self.key == other.key
    end

    def <=>(other)
      [sort_order, self.class.name] <=> [other.sort_order, other.class.name]
    end

    def method_missing(*args)
      context.send(*args)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metamagic-3.1.0 lib/metamagic/tag.rb