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
1bccdcdc
Commit
1bccdcdc
authored
May 09, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preliminary untag work
parent
b4d89299
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
tags.rb
lib/noah/models/tags.rb
+18
-0
taggable.rb
lib/noah/taggable.rb
+18
-0
No files found.
lib/noah/models/tags.rb
View file @
1bccdcdc
...
...
@@ -6,6 +6,15 @@ module Noah
index
:members
index
:name
def
delete
self
.
members
.
each_value
do
|
member_array
|
member_array
.
each
do
|
member
|
member
.
tags
.
key
.
srem
"
#{
self
.
id
}
"
end
end
super
end
def
validate
super
assert_present
:name
...
...
@@ -29,6 +38,15 @@ module Noah
hsh
end
def
delete_member
(
node
)
nc
=
class_to_lower
(
node
.
class
.
to_s
)
+
"s"
if
self
.
members
[
nc
.
to_sym
].
member?
(
node
)
Ohm
.
redis
.
srem
(
"
#{
self
.
key
}
:members"
,
"
#{
node
.
key
}
"
)
node
.
untag!
(
self
.
name
)
unless
node
.
tags
.
member?
(
self
)
==
false
end
self
.
save
end
def
to_hash
h
=
{
:name
=>
name
,
:created_at
=>
created_at
,
:updated_at
=>
updated_at
}
h
.
merge!
(
members_to_hash
)
...
...
lib/noah/taggable.rb
View file @
1bccdcdc
...
...
@@ -17,9 +17,27 @@ module Noah::Taggable
tags
<<
my_tag
my_tag
.
members
=
self
end
self
.
save
end
def
untag!
(
tag_name
)
case
tag_name
.
class
.
to_s
when
"Array"
tag_name
.
each
do
|
t
|
my_tag
=
::
Noah
::
Tag
.
find
(
:name
=>
t
).
first
if
self
.
tags
.
member?
(
my_tag
)
self
.
tags
.
key
.
srem
"
#{
my_tag
.
id
}
"
my_tag
.
delete_member
(
self
)
end
end
else
my_tag
=
::
Noah
::
Tag
.
find
(
:name
=>
tag_name
).
first
if
self
.
tags
.
member?
(
my_tag
)
self
.
tags
.
key
.
srem
"
#{
my_tag
.
id
}
"
my_tag
.
delete_member
(
self
)
end
end
self
.
save
end
def
to_hash
...
...
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