lib/ahoy/model.rb in ahoy_matey-1.6.1 vs lib/ahoy/model.rb in ahoy_matey-2.0.0
- old
+ new
@@ -1,37 +1,15 @@
module Ahoy
module Model
- def visitable(name = nil, options = {})
- if name.is_a?(Hash)
- options = name
- name = nil
- end
- name ||= :visit
+ def visitable(name = :visit, **options)
class_eval do
- belongs_to name, options
- before_create :set_visit
+ belongs_to(name, optional: true, class_name: "Ahoy::Visit", **options)
+ before_create :set_ahoy_visit
end
class_eval %{
- def set_visit
+ def set_ahoy_visit
self.#{name} ||= RequestStore.store[:ahoy].try(:visit)
end
}
- end
-
- # deprecated
-
- def ahoy_visit
- class_eval do
- warn "[DEPRECATION] ahoy_visit is deprecated"
-
- belongs_to :user, polymorphic: true
-
- def landing_params
- @landing_params ||= begin
- warn "[DEPRECATION] landing_params is deprecated"
- Deckhands::UtmParameterDeckhand.new(landing_page).landing_params
- end
- end
- end
end
end
end