-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ActiveTouch::Network and create a map of touches as application i…
…s initialized.
- Loading branch information
Kevin Pheasey
committed
Dec 19, 2015
1 parent
19d6c81
commit dab603d
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module ActiveTouch | ||
|
||
class << self | ||
attr_accessor :network | ||
end | ||
|
||
def self.network | ||
@network ||= Network.new | ||
end | ||
|
||
class Network | ||
|
||
attr_accessor :map | ||
|
||
def initialize | ||
@map = {} | ||
end | ||
|
||
# @param caller [String] | ||
# @param touched [String, Array(String)] | ||
# @param watch [Array(Symbol)] | ||
# @return [void] | ||
def add_touch(caller, touched, watch) | ||
map[caller] ||= [] | ||
|
||
if touched.is_a? Array | ||
touched.each { |t| map[caller] << { class: t, attributes: watch } } | ||
else | ||
map[caller] << { class: touched, attributes: watch } | ||
end | ||
end | ||
|
||
end | ||
|
||
end |