Class: Jpmobile::Filter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/jpmobile/filter.rb

Overview

文字コードフィルタのベースクラス。

Direct Known Subclasses

Emoticon::Inner, Emoticon::Outer, FilterTable, Sjis

Instance Method Summary (collapse)

Instance Method Details

- (Object) after(controller)

内部コードから外部コードに変換



36
37
38
39
40
41
# File 'lib/jpmobile/filter.rb', line 36

def after(controller)
  if respond_to?(:to_external) && apply_outgoing?(controller) && controller.response.body.is_a?(String)
    controller.response.body = to_external(controller.response.body, controller)
    after_after(controller) if respond_to? :after_after
  end
end

- (Boolean) apply_incoming?(controller)

入力時(params)にこのフィルタを適用するか

Returns:

  • (Boolean)


43
# File 'lib/jpmobile/filter.rb', line 43

def apply_incoming?(controller); true; end

- (Boolean) apply_outgoing?(controller)

出力時(response.body)にこのフィルタを適用するべきか

Returns:

  • (Boolean)


45
# File 'lib/jpmobile/filter.rb', line 45

def apply_outgoing?(controller); true; end

- (Object) before(controller)

外部コードから内部コードに変換



28
29
30
31
32
33
34
# File 'lib/jpmobile/filter.rb', line 28

def before(controller)
  if respond_to?(:to_internal) && apply_incoming?(controller)
    Util.deep_apply(controller.params) do |value|
      value = to_internal(value, controller)
    end
  end
end