lib/avo/base_action.rb in avo-0.5.0.beta9 vs lib/avo/base_action.rb in avo-0.5.0.beta10

- old
+ new

@@ -23,17 +23,17 @@ def initialize(model: nil, resource: nil, user: nil) self.class.model = model if model.present? self.class.resource = resource if resource.present? self.class.user = user if user.present? - self.class.message ||= I18n.t('avo.are_you_sure_you_want_to_run_this_option') - self.class.confirm_button_label ||= I18n.t('avo.run') - self.class.cancel_button_label ||= I18n.t('avo.cancel') + self.class.message ||= I18n.t("avo.are_you_sure_you_want_to_run_this_option") + self.class.confirm_button_label ||= I18n.t("avo.run") + self.class.cancel_button_label ||= I18n.t("avo.cancel") @response ||= {} @response[:message_type] ||= :notice - @response[:message] ||= I18n.t('avo.action_ran_successfully') + @response[:message] ||= I18n.t("avo.action_ran_successfully") end def context self.class.context end @@ -48,20 +48,20 @@ def get_fields get_field_definitions.map do |field| field.hydrate(action: self, model: @model) end - .select do |field| + .select do |field| field.visible? end end def get_attributes_for_action get_fields.map do |field| [field.id, field.value] end - .to_h + .to_h end def handle_action(models:, fields:) avo_fields = get_fields.map { |field| [field.id, field] }.to_h @@ -73,53 +73,53 @@ processed_fields = processed_fields.to_h else processed_fields = {} end - result = self.handle models: models, fields: processed_fields + handle models: models, fields: processed_fields self end def param_id - self.class.to_s.demodulize.underscore.gsub '/', '_' + self.class.to_s.demodulize.underscore.tr "/", "_" end def succeed(text) - self.response[:message_type] = :notice - self.response[:message] = text + response[:message_type] = :notice + response[:message] = text self end def fail(text) - self.response[:message_type] = :alert - self.response[:message] = text + response[:message_type] = :alert + response[:message] = text self end def redirect_to(path = nil, &block) - self.response[:type] = :redirect - if block.present? - self.response[:path] = block + response[:type] = :redirect + response[:path] = if block.present? + block else - self.response[:path] = path + path end self end def reload - self.response[:type] = :reload + response[:type] = :reload self end def download(path, filename) - self.response[:type] = :download - self.response[:path] = path - self.response[:filename] = filename + response[:type] = :download + response[:path] = path + response[:filename] = filename self end end end