Cinch::Syncable

Public Instance Methods

attr(attribute, data = false, unsync = false) click to toggle source

@api private

# File lib/cinch/syncable.rb, line 46
def attr(attribute, data = false, unsync = false)
  unless unsync
    if @when_requesting_synced_attribute
      @when_requesting_synced_attribute.call(attribute)
    end
    wait_until_synced(attribute)
  end

  if data
    return @data[attribute]
  else
    return instance_variable_get("@#{attribute}")
  end
end
mark_as_synced(attribute) click to toggle source

@api private @return [void]

# File lib/cinch/syncable.rb, line 63
def mark_as_synced(attribute)
  @synced_attributes << attribute
end
sync(attribute, value, data = false) click to toggle source

@api private @return [void]

# File lib/cinch/syncable.rb, line 17
def sync(attribute, value, data = false)
  if data
    @data[attribute] = value
  else
    instance_variable_set("@#{attribute}", value)
  end
  @synced_attributes << attribute
end
synced?(attribute) click to toggle source

@return [Boolean] @api private

# File lib/cinch/syncable.rb, line 28
def synced?(attribute)
  @synced_attributes.include?(attribute)
end
unsync(attribute) click to toggle source

@return [void] @api private

# File lib/cinch/syncable.rb, line 34
def unsync(attribute)
  @synced_attributes.delete(attribute)
end
unsync_all() click to toggle source

@return [void] @api private @since 1.0.1

# File lib/cinch/syncable.rb, line 41
def unsync_all
  @synced_attributes.clear
end
wait_until_synced(attr) click to toggle source

Blocks until the object is synced.

@return [void] @api private

# File lib/cinch/syncable.rb, line 7
def wait_until_synced(attr)
  attr = attr.to_sym
  while true
    return if @synced_attributes.include?(attr)
    sleep 0.1
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.