diff options
author | Javan Makhmali <javan@javan.us> | 2018-02-08 15:48:45 -0500 |
---|---|---|
committer | Javan Makhmali <javan@javan.us> | 2018-02-08 15:48:45 -0500 |
commit | 5012d645daa65ef776d27eb973b3278302c36cad (patch) | |
tree | be85c13f8f2fef097f1547e039cb5459d4cf023c | |
parent | 38e1f12d79ec3313e42643e52f2d10cb5fbd5d5d (diff) | |
download | rails-5012d645daa65ef776d27eb973b3278302c36cad.tar.gz rails-5012d645daa65ef776d27eb973b3278302c36cad.tar.bz2 rails-5012d645daa65ef776d27eb973b3278302c36cad.zip |
Add initial ActiveRecord extension: `active_text_attribute`
-rw-r--r-- | lib/active_text.rb | 1 | ||||
-rw-r--r-- | lib/active_text/attribute.rb | 11 | ||||
-rw-r--r-- | lib/active_text/engine.rb | 6 |
3 files changed, 18 insertions, 0 deletions
diff --git a/lib/active_text.rb b/lib/active_text.rb index e9dfaeefe4..1981abc4c6 100644 --- a/lib/active_text.rb +++ b/lib/active_text.rb @@ -7,6 +7,7 @@ module ActiveText autoload :Attachable autoload :Attachment + autoload :Attribute autoload :Content autoload :Fragment autoload :HtmlConversion diff --git a/lib/active_text/attribute.rb b/lib/active_text/attribute.rb new file mode 100644 index 0000000000..577adde83a --- /dev/null +++ b/lib/active_text/attribute.rb @@ -0,0 +1,11 @@ +module ActiveText + module Attribute + extend ActiveSupport::Concern + + class_methods do + def active_text_attribute(attribute_name) + serialize(attribute_name, ActiveText::Content) + end + end + end +end diff --git a/lib/active_text/engine.rb b/lib/active_text/engine.rb index d9dfff6122..3f076ab321 100644 --- a/lib/active_text/engine.rb +++ b/lib/active_text/engine.rb @@ -4,5 +4,11 @@ module ActiveText class Engine < Rails::Engine isolate_namespace ActiveText config.eager_load_namespaces << ActiveText + + initializer "active_text.attribute" do + ActiveSupport.on_load(:active_record) do + include ActiveText::Attribute + end + end end end |