# File core/plugin/world/service.rb, line 37 def primary world, = Plugin.filtering(:world_current, nil) world end
module Service
begin rdoc¶ ↑
Twitter APIとmikutterプラグインのインターフェイス
end¶ ↑
Public Class Methods
add_service(token, secret)
click to toggle source
新しくサービスを認証する
# File core/plugin/world/service.rb, line 61 def add_service(token, secret) type_strict token => String, secret => String twitter = MikuTwitter.new twitter.consumer_key = Environment::TWITTER_CONSUMER_KEY twitter.consumer_secret = Environment::TWITTER_CONSUMER_SECRET twitter.a_token = token twitter.a_secret = secret (twitter/:account/:verify_credentials).user.next { |user| id = "twitter#{user.id}".to_sym Plugin::World::Keep.account_register id, { provider: :twitter, slug: id, token: token, secret: secret, user: { id: user[:id], idname: user[:idname], name: user[:name], profile_image_url: user[:profile_image_url] } } service = Service[id] Plugin.call(:service_registered, service) service } end
destroy(service)
click to toggle source
# File core/plugin/world/service.rb, line 88 def destroy(service) Plugin.call(:world_destroy, service) end
each(*args, &proc)
click to toggle source
::instances.eachと同じ
# File core/plugin/world/service.rb, line 30 def each(*args, &proc) instances.each(*args, &proc) end
instances()
click to toggle source
存在するServiceオブジェクトを全て返す。 つまり、投稿権限のある「自分」のアカウントを全て返す。
Return¶ ↑
- Array
-
アカウントを示すDiva::Modelを各要素に持った配列。
# File core/plugin/world/service.rb, line 20 def instances Enumerator.new{|y| Plugin.filtering(:worlds, y) }.select{|world| world.class.slug == :twitter } end
Also aliased as: services
primary()
click to toggle source
現在アクティブになっているサービスを返す。 基本的に、あるアクションはこれが返すアカウントに対して行われなければならない。
Return¶ ↑
アクティブなアカウントに対応するModelか、存在しない場合はnil
Also aliased as: primary_service
primary!()
click to toggle source
現在アクティブになっているサービスを返す。 ::primary とちがって、サービスが一つも登録されていない時、例外を発生させる。
Exceptions¶ ↑
- Plugin::World::NotExistError
-
(選択されている)Serviceが存在しない
Return¶ ↑
アクティブなService
# File core/plugin/world/service.rb, line 49 def primary! result = primary raise Plugin::World::NotExistError, 'World does not exists.' unless result result end
remove_service(service)
click to toggle source
# File core/plugin/world/service.rb, line 91 def remove_service(service) destroy(service) end
set_primary(service)
click to toggle source
# File core/plugin/world/service.rb, line 55 def set_primary(service) Plugin.call(:world_change_current, service) self end