more documentation
This commit is contained in:
parent
3f6c207f59
commit
88b67d9a83
4 changed files with 12 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# diaspora* federation library
|
# diaspora* federation library
|
||||||
|
|
||||||
**a library that provides functionalities needed for the diaspora* federation protocol**
|
**A library that provides functionalities needed for the diaspora* federation protocol**
|
||||||
|
|
||||||
[](https://travis-ci.org/SuperTux88/diaspora_federation)
|
[](https://travis-ci.org/SuperTux88/diaspora_federation)
|
||||||
[](https://codeclimate.com/github/SuperTux88/diaspora_federation)
|
[](https://codeclimate.com/github/SuperTux88/diaspora_federation)
|
||||||
|
|
@ -57,7 +57,7 @@ After the first stable release, this repo will be moved to the [diaspora organiz
|
||||||
|
|
||||||
## Diaspora
|
## Diaspora
|
||||||
|
|
||||||
a privacy-aware, distributed, open source social network
|
A privacy-aware, distributed, open source social network
|
||||||
|
|
||||||
Links:
|
Links:
|
||||||
[Project site](https://diasporafoundation.org) |
|
[Project site](https://diasporafoundation.org) |
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ module DiasporaFederation
|
||||||
# # do something
|
# # do something
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
#
|
||||||
|
# @param [Proc] block the callbacks to define
|
||||||
def define_callbacks(&block)
|
def define_callbacks(&block)
|
||||||
@callbacks.instance_eval(&block)
|
@callbacks.instance_eval(&block)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,10 @@ module DiasporaFederation
|
||||||
# callbacks.on :some_event do |arg1|
|
# callbacks.on :some_event do |arg1|
|
||||||
# # do something
|
# # do something
|
||||||
# end
|
# end
|
||||||
|
#
|
||||||
|
# @param [Symbol] event the event key
|
||||||
|
# @param [Proc] callback the callback block
|
||||||
|
# @raise [ArgumentError] if the event key is undefined or has already a handler
|
||||||
def on(event, &callback)
|
def on(event, &callback)
|
||||||
raise ArgumentError, "Undefined event #{event}" unless @events.include? event
|
raise ArgumentError, "Undefined event #{event}" unless @events.include? event
|
||||||
raise ArgumentError, "Already defined event #{event}" if @handlers.has_key? event
|
raise ArgumentError, "Already defined event #{event}" if @handlers.has_key? event
|
||||||
|
|
@ -34,7 +38,9 @@ module DiasporaFederation
|
||||||
# @example
|
# @example
|
||||||
# callbacks.trigger :some_event, "foo"
|
# callbacks.trigger :some_event, "foo"
|
||||||
#
|
#
|
||||||
|
# @param [Symbol] event the event key
|
||||||
# @return [Object] the return-value of the callback
|
# @return [Object] the return-value of the callback
|
||||||
|
# @raise [ArgumentError] if the event key is undefined
|
||||||
def trigger(event, *args)
|
def trigger(event, *args)
|
||||||
raise ArgumentError, "Undefined event #{event}" unless @events.include? event
|
raise ArgumentError, "Undefined event #{event}" unless @events.include? event
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,12 +76,14 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
|
|
||||||
# checks if the name is a +Symbol+ or a +String+
|
# checks if the name is a +Symbol+ or a +String+
|
||||||
|
# @param [String, Symbol] name the name to check
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def name_valid?(name)
|
def name_valid?(name)
|
||||||
name.instance_of?(Symbol) || name.instance_of?(String)
|
name.instance_of?(Symbol) || name.instance_of?(String)
|
||||||
end
|
end
|
||||||
|
|
||||||
# checks if the type extends {Entity}
|
# checks if the type extends {Entity}
|
||||||
|
# @param [Class] type the type to check
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def type_valid?(type)
|
def type_valid?(type)
|
||||||
[type].flatten.all? { |type|
|
[type].flatten.all? { |type|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue