Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rumoji
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
rumoji
Commits
47eb5880
Unverified
Commit
47eb5880
authored
Feb 16, 2018
by
Colin Rice
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a hook to store emojis in db dynamically.
parent
db6bf446
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
lib/rumoji/emoji.rb
+4
-0
lib/rumoji/extensions.rb
+8
-0
lib/rumoji/mixin.rb
+23
-0
No files found.
lib/rumoji/emoji.rb
View file @
47eb5880
# -*- encoding: utf-8 -*-
require
'rumoji/mixin'
require
'rumoji/extensions'
module
Rumoji
class
Emoji
...
...
lib/rumoji/extensions.rb
0 → 100644
View file @
47eb5880
class
ApplicationRecord
def
self
.
stores_emoji_characters
(
*
attributes
)
return
unless
table_exists?
Rumoji
::
Mixin
.
inject_methods
(
self
,
attributes
)
end
end
\ No newline at end of file
lib/rumoji/mixin.rb
0 → 100644
View file @
47eb5880
module
Rumoji
module
Mixin
def
self
.
inject_methods
(
model
,
attributes
)
attributes
.
each
do
|
attribute
|
model
.
class_eval
<<-
RUBY
,
__FILE__
,
__LINE__
+
1
before_save do
unless respond_to?("
#{
attribute
}
=")
raise ArgumentError.new('
#{
model
}
must respond to
#{
attribute
}
= in order for Rumoji to store emoji.')
end
self.
#{
attribute
}
= Rumoji.encode(self.
#{
attribute
}
)
true
end
def
#{
attribute
}
Rumoji.decode(super)
end
RUBY
end
end
end
end
\ No newline at end of file
李福中
@lifuzho
mentioned in commit
f1d1cac7
Jan 18, 2022
mentioned in commit
f1d1cac7
mentioned in commit f1d1cac7d5c9628dd0328d83a62cc51e7d492fca
Toggle commit list
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