Skip to content

Commit

Permalink
Deprecate essence classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed Sep 3, 2022
1 parent feb5e6f commit b5568f5
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/alchemy/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require_dependency "alchemy/content/factory"

module Alchemy
# @deprecated
class Content < BaseRecord
include Alchemy::Logger
include Alchemy::Hints
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_audio.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

module Alchemy
# @deprecated
class EssenceAudio < ActiveRecord::Base
acts_as_essence(
ingredient_column: :attachment,
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_boolean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Stores boolean values.
# Provides a checkbox in the editor views.
module Alchemy
# @deprecated
class EssenceBoolean < BaseRecord
acts_as_essence ingredient_column: "value"
end
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#

module Alchemy
# @deprecated
class EssenceDate < BaseRecord
acts_as_essence ingredient_column: "date"

Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#

module Alchemy
# @deprecated
class EssenceFile < BaseRecord
belongs_to :attachment, optional: true
acts_as_essence ingredient_column: "attachment"
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_headline.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

module Alchemy
# @deprecated
class EssenceHeadline < BaseRecord
acts_as_essence

Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#

module Alchemy
# @deprecated
class EssenceHtml < BaseRecord
acts_as_essence ingredient_column: "source"

Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#

module Alchemy
# @deprecated
class EssenceLink < BaseRecord
acts_as_essence ingredient_column: "link"
end
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_node.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

module Alchemy
# @deprecated
class EssenceNode < BaseRecord
acts_as_essence(
ingredient_column: :node,
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_page.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

module Alchemy
# @deprecated
class EssencePage < BaseRecord
acts_as_essence(
ingredient_column: :page,
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_picture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#

module Alchemy
# @deprecated
class EssencePicture < BaseRecord
include Alchemy::PictureThumbnails

Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_picture_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Alchemy
# Renders an essence picture view
# @deprecated
class EssencePictureView
include ActionView::Helpers::AssetTagHelper
include ActionView::Helpers::UrlHelper
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_richtext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#

module Alchemy
# @deprecated
class EssenceRichtext < BaseRecord
acts_as_essence preview_text_column: "stripped_body"

Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# Provides a select box that stores string values.
module Alchemy
# @deprecated
class EssenceSelect < BaseRecord
acts_as_essence ingredient_column: "value"
end
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#

module Alchemy
# @deprecated
class EssenceText < BaseRecord
acts_as_essence
end
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/essence_video.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

module Alchemy
# @deprecated
class EssenceVideo < ActiveRecord::Base
acts_as_essence(
ingredient_column: :attachment,
Expand Down
23 changes: 22 additions & 1 deletion lib/alchemy/essence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ def self.included(base)
# * several getters (ie: page, element, content, ingredient, preview_text)
#
module ClassMethods
DEPRECATED_ESSENCE_CLASSES = %w[
Alchemy::EssenceAudio
Alchemy::EssenceBoolean
Alchemy::EssenceDate
Alchemy::EssenceFile
Alchemy::EssenceHeadline
Alchemy::EssenceHtml
Alchemy::EssenceLink
Alchemy::EssenceNode
Alchemy::EssencePage
Alchemy::EssencePicture
Alchemy::EssenceRichtext
Alchemy::EssenceSelect
Alchemy::EssenceText
Alchemy::EssenceVideo
]

# Turn any active record model into an essence by calling this class method
#
# @option options [String || Symbol] ingredient_column ('body')
Expand All @@ -23,8 +40,12 @@ module ClassMethods
# The column the the validations run against.
# @option options [String || Symbol] preview_text_column (ingredient_column)
# Specify the column for the preview_text method.
#
# @deprecated
def acts_as_essence(options = {})
if !DEPRECATED_ESSENCE_CLASSES.include?(name)
Alchemy::Deprecation.warn "Please create a custom Alchemy::Ingredient for #{self.name} instead"
end

register_as_essence_association!

configuration = {
Expand Down

0 comments on commit b5568f5

Please sign in to comment.