lib/avo/base_resource.rb in avo-3.0.1.beta24 vs lib/avo/base_resource.rb in avo-3.0.2

- old
+ new

@@ -8,10 +8,12 @@ include Avo::Concerns::HasControls include Avo::Concerns::HasStimulusControllers include Avo::Concerns::ModelClassConstantized include Avo::Concerns::HasDescription include Avo::Concerns::HasHelpers + include Avo::Concerns::Hydration + include Avo::Concerns::Pagination # Avo::Current methods delegate :context, to: Avo::Current def current_user Avo::Current.user @@ -230,10 +232,11 @@ delegate :plural_name, to: :class delegate :underscore_name, to: :class delegate :underscore_name, to: :class delegate :find_record, to: :class delegate :model_key, to: :class + delegate :tab, to: :items_holder def initialize(record: nil, view: nil, user: nil, params: nil) @view = Avo::ViewInquirer.new(view) if view.present? @user = user if user.present? @params = params if params.present? @@ -250,11 +253,11 @@ end end end def detect_fields - self.items_holder = Avo::Resources::Items::Holder.new + self.items_holder = Avo::Resources::Items::Holder.new(parent: self) # Used in testing to replace items if temporary_items.present? instance_eval(&temporary_items) else @@ -319,17 +322,13 @@ klass[:arguments] end end - def hydrate(record: nil, view: nil, user: nil, params: nil) - @view = Avo::ViewInquirer.new(view) if view.present? - @user = user if user.present? - @params = params if params.present? + def hydrate(...) + super(...) - if record.present? - @record = record - + if @record.present? hydrate_model_with_default_values if @view&.new? end self end