Sha256: 68eb11995a0590e1ba4774c5c2417f2418793b26528752c11f553f36c8e260ac
Contents?: true
Size: 741 Bytes
Versions: 3
Compression:
Stored size: 741 Bytes
Contents
module Emojimmy module Mixin def self.inject_methods(model, attributes) attributes.each do |attribute| model.class_eval <<-RUBY, __FILE__, __LINE__ + 1 # Before saving the record, convert the attribute value before_save do unless respond_to?("#{attribute}=") raise ArgumentError.new('#{model} must respond to #{attribute}= in order for Emojimmy to store emoji characters in it.') end self.#{attribute} = Emojimmy.emoji_to_token(self.#{attribute}) end # When calling the attribute name, convert its value def #{attribute} Emojimmy.token_to_emoji(super) end RUBY end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
emojimmy-0.2.2 | lib/emojimmy/mixin.rb |
emojimmy-0.2.1 | lib/emojimmy/mixin.rb |
emojimmy-0.2 | lib/emojimmy/mixin.rb |