Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
Noah
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Noah
Commits
fa4b0928
Commit
fa4b0928
authored
Feb 27, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more notes and stubbing
parent
976841a0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
noah.rb
lib/noah.rb
+3
-0
models.rb
lib/noah/models.rb
+8
-3
ephemerals.rb
lib/noah/models/ephemerals.rb
+8
-0
No files found.
lib/noah.rb
View file @
fa4b0928
module
Noah
PROTECTED_PATHS
=
%w[a c h s w]
end
begin
require
'yajl'
rescue
LoadError
...
...
lib/noah/models.rb
View file @
fa4b0928
...
...
@@ -9,8 +9,9 @@ module Noah
model
.
send
:include
,
Ohm
::
Callbacks
model
.
send
:include
,
Ohm
::
ExtraValidations
model
.
after
:save
,
:notify_via_redis_save
#model.after :create, :notify_via_redis_create
# removing this as it's simply redundant
# model.after :save, :notify_via_redis_save
model
.
after
:create
,
:notify_via_redis_create
model
.
after
:update
,
:notify_via_redis_update
model
.
before
:delete
,
:stash_name
model
.
after
:delete
,
:notify_via_redis_delete
...
...
@@ -46,6 +47,7 @@ module Noah
def
patternize_me
"//noah/
#{
self
.
class_to_lower
}
/
#{
name
.
gsub
(
/^\//
,
''
)
}
"
end
def
stash_name
@deleted_name
=
self
.
name
end
...
...
@@ -60,7 +62,7 @@ module Noah
o
[
:db
].
nil?
?
"
#{
o
[
:url
].
split
(
'/'
).
last
}
"
:
"
#{
o
[
:db
]
}
"
end
[
"
save"
,
"
create"
,
"update"
,
"delete"
].
each
do
|
meth
|
[
"create"
,
"update"
,
"delete"
].
each
do
|
meth
|
class_eval
do
define_method
(
"notify_via_redis_
#{
meth
}
"
.
to_sym
)
do
db
=
self
.
dbnum
...
...
@@ -69,6 +71,9 @@ module Noah
#pub_category = "#{db}:noah.#{self.class.to_s}[#{name}].#{meth}"
pub_category
=
"
#{
self
.
patternize_me
}
.
#{
meth
}
"
Ohm
.
redis
.
publish
(
pub_category
,
self
.
to_hash
.
merge
({
"action"
=>
meth
,
"pubcategory"
=>
pub_category
}).
to_json
)
# The following provides a post post-action hook. It allows a class to provide it's own handling after the fact
# good example is in [Noah::Ephemeral] where it's used to check for/clean up expired ephemeral nodes entries
self
.
send
(
"
#{
meth
}
_hook"
.
to_sym
)
unless
self
.
protected_methods
.
member?
(
"
#{
meth
}
_hook"
.
to_sym
)
==
false
end
end
...
...
lib/noah/models/ephemerals.rb
View file @
fa4b0928
...
...
@@ -19,7 +19,15 @@ module Noah
protected
def
save_hook
# called after any create,update,delete
# logic needed to expire any orphaned ephemerals
end
private
def
path_protected?
(
path_part
)
# Check for protected paths in ephemeral nodes
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment