Sha256: 9f136f0c07e98bc00cbdf70bc813f571145c6ea24ae2e806a5b7f0455ee87d49

Contents?: true

Size: 1015 Bytes

Versions: 12

Compression:

Stored size: 1015 Bytes

Contents

# -*- encoding : utf-8 -*-

module PhraseApp
  module InContextEditor
    module Delegate
      class Base < String
        def to_s
          "#{decorated_key_name}"
        end
        alias :camelize :to_s
        alias :underscore :to_s
        alias :classify :to_s
        alias :dasherize :to_s
        alias :tableize :to_s

        def self.log(message)
          message = "phrase: #{message}"
          if defined?(Rails) and Rails.respond_to?(:logger)
            Rails.logger.warn(message)
          else
            $stderr.puts message
          end
        end

      protected
        def decorated_key_name
          "#{PhraseApp::InContextEditor.prefix}phrase_#{normalized_display_key}#{PhraseApp::InContextEditor.suffix}"
        end

        def normalized_display_key
          unless @display_key.nil?
            @display_key.gsub("<", "[[[[[[html_open]]]]]]").gsub(">", "[[[[[[html_close]]]]]]")
          else
            @display_key
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
phraseapp-in-context-editor-ruby-1.2.0 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.1.0 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.0.6 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.0.5 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.0.4 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.0.3 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.0.2 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.0.1 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.0.0 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.0.0rc3 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.0.0rc2 lib/phraseapp-in-context-editor-ruby/delegate.rb
phraseapp-in-context-editor-ruby-1.0.0rc1 lib/phraseapp-in-context-editor-ruby/delegate.rb