Sha256: 87891907578a37afa9fedd1522da692198eb92579142545b7acad4c70d4f9740

Contents?: true

Size: 667 Bytes

Versions: 2

Compression:

Stored size: 667 Bytes

Contents

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

    def initialize(context, key, value)
      @context, @key, @value = context, key, 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

2 entries across 2 versions & 1 rubygems

Version Path
metamagic-3.0.3 lib/metamagic/tag.rb
metamagic-3.0.2 lib/metamagic/tag.rb