Class: JIJI::Plugin::SecuritiesPluginManager

Inherits:
Object
  • Object
show all
Defined in:
lib/jiji/plugin/securities_plugin.rb

Overview

証券会社アクセスプラグインのマネージャ

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSecuritiesPluginManager

Returns a new instance of SecuritiesPluginManager.



96
97
98
99
# File 'lib/jiji/plugin/securities_plugin.rb', line 96

def initialize
  @mutex = Mutex.new
  @selected = nil
end

Instance Attribute Details

#confObject

Returns the value of attribute conf.



130
131
132
# File 'lib/jiji/plugin/securities_plugin.rb', line 130

def conf
  @conf
end

#server_loggerObject

Returns the value of attribute server_logger.



129
130
131
# File 'lib/jiji/plugin/securities_plugin.rb', line 129

def server_logger
  @server_logger
end

Instance Method Details

#allObject

登録済みプラグインの一覧を返す。

return

登録済みプラグインの配列



103
104
105
# File 'lib/jiji/plugin/securities_plugin.rb', line 103

def all
  JIJI::Plugin.get( JIJI::Plugin::SecuritiesPlugin::FUTURE_NAME )
end

#closeObject

プラグインを破棄する。



124
125
126
127
128
# File 'lib/jiji/plugin/securities_plugin.rb', line 124

def close
  @mutex.synchronize {
    @selected.destroy_plugin if @selected
  }
end

#selectedObject

選択されたプラグインインスタンスを取得する。

return

選択されているプラグインインスタンス



109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/jiji/plugin/securities_plugin.rb', line 109

def selected
  return @mutex.synchronize {
    unless @selected
      id = conf.get([:securities, :type], "illegal" ).to_sym
      @selected = all.find {|plugin|
        id == plugin.plugin_id.to_sym
      }
      raise FatalError.new( JIJI::ERROR_NOT_FOUND, "Securities plugin isnot found. plugin_id=#{id}" ) unless @selected
      @selected.init_plugin( conf.get( [:securities], {} ), @server_logger )
    end
    @selected
  }
end