Sha256: 3b2aedadb4aa1fe5becfa731ca2568914f5c639be60e9286acc810d5cdb3ab05

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 KB

Contents

# -*- encoding : utf-8 -*-
module Card::Chunk
  class Reference < Abstract
    attr_accessor :referee_name, :name

    def referee_name
      return if name.nil?
        
      @referee_name ||= ( render_obj name ).to_name
      @referee_name = @referee_name.to_absolute(card.cardname).to_name
    end

    def referee_card
      @referee_card ||= referee_name && Card.fetch( referee_name )
    end

    def referee_id
      referee_card and referee_card.id
    end

    def replace_name_reference old_name, new_name
      #warn "ref rnr #{inspect}, #{old_name}, #{new_name}"
      @referee_card = @referee_name = nil
      if Card::Content===name
        name.find_chunks(Chunk::Reference).each { |chunk| chunk.replace_reference old_name, new_name }
      else
        @name = name.to_name.replace_part( old_name, new_name )
      end
    end
    
    def render_obj raw
      if format && Card::Content===raw
        format.card.references_expired = nil # don't love this; this is to keep from running update_references again
        format.process_content raw
      else
        raw
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wagn-1.13.0 mod/core/chunk/reference.rb
wagn-1.13.0.pre2 mods/core/chunks/reference.rb
wagn-1.13.0.pre1 mods/core/chunks/reference.rb
wagn-1.13.0.pre mods/core/chunks/reference.rb
wagn-1.12.13 mods/core/chunks/reference.rb
wagn-1.12.12 mods/core/chunks/reference.rb
wagn-1.12.11 mods/core/chunks/reference.rb
wagn-1.12.10 mods/core/chunks/reference.rb
wagn-1.12.9 mods/core/chunks/reference.rb
wagn-1.12.8 mods/core/chunks/reference.rb
wagn-1.12.7 mods/core/chunks/reference.rb