Sha256: 5f6a3524667aa8364fd2ef4c2892bb1349daca99e2ac8ecbf048611f63018695
Contents?: true
Size: 570 Bytes
Versions: 2
Compression:
Stored size: 570 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 self.#{attribute} = Emojimmy.emoji_to_text(self.#{attribute}) end # When calling the attribute name, convert its value def #{attribute} Emojimmy.text_to_emoji(read_attribute(#{attribute.inspect})) end RUBY end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
emojimmy-0.1.2 | lib/emojimmy/mixin.rb |
emojimmy-0.1.1 | lib/emojimmy/mixin.rb |