class Plugin::Intent::IntentToken

Public Class Methods

new(*rest) click to toggle source
Calls superclass method
# File core/plugin/intent/model/intent_token.rb, line 14
def initialize(*rest)
  super
  self[:source] = self[:model]
end
open(*args) click to toggle source

引数の情報からIntentTokenを作成し、それを開く

# File core/plugin/intent/model/intent_token.rb, line 10
def self.open(*args)
  self.new(*args).open
end

Public Instance Methods

ancestors() click to toggle source

self から親のIntentTokenを再帰的に遡って、そのIntentTokenを引数に繰り返すEnumeratorを返す。

Return

Enumerator

IntentTokenを列挙する

# File core/plugin/intent/model/intent_token.rb, line 45
def ancestors
  Enumerator.new do |yielder|
    cur = self
    loop do
      break unless cur
      yielder << cur
      cur = cur.parent
    end
  end
end
forward() click to toggle source
# File core/plugin/intent/model/intent_token.rb, line 38
def forward
  Plugin.call(:intent_forward, self)
end
intent_ancestors() click to toggle source

ancestorsと同じようなもの。ただし、IntentToken#intentに関して繰り返す。

Return

Enumerator

Intentを列挙する

# File core/plugin/intent/model/intent_token.rb, line 59
def intent_ancestors
  ancestors.lazy.map(&:intent)
end
open() click to toggle source

設定された情報を使ってURI又はModelを開く

# File core/plugin/intent/model/intent_token.rb, line 20
def open
  if model?
    Plugin.call(:open, self)
  else
    Deferred.new{
      Diva.Model(intent.model_slug).find_by_uri(uri)
    }.next{|m|
      Delayer::Deferred.fail("#{intent.model_slug}(#{uri}) does not exists.") unless m
      self.model = m
      Plugin.call(:open, self)
    }.trap{|err|
      error err
      forward
    }
  end
  self
end