Skip to content

Commit

Permalink
Extract to variable
Browse files Browse the repository at this point in the history
  • Loading branch information
fidel authored and mostlyobvious committed Jan 30, 2023
1 parent 924aeae commit 8d159f5
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ class Event < ::ActiveRecord::Base
self.primary_key = :id
self.table_name = "event_store_events"

attribute :data, ->(type) { %i[json jsonb].include?(type.type) ? ActiveModel::Type::Value.new : type }
attribute :metadata, ->(type) { %i[json jsonb].include?(type.type) ? ActiveModel::Type::Value.new : type }
skip_json_serialization = ->(type) { %i[json jsonb].include?(type.type) ? ActiveModel::Type::Value.new : type }

attribute :data, skip_json_serialization
attribute :metadata, skip_json_serialization
end
private_constant :Event

Expand Down

0 comments on commit 8d159f5

Please sign in to comment.