Sha256: 1a3644d69f6c5c70e711b46277f67645930ab4feee5cdc1aaefaa1f0583e77ab

Contents?: true

Size: 582 Bytes

Versions: 7

Compression:

Stored size: 582 Bytes

Contents

# frozen_string_literal: true

module Scribo
  class FormDrop < Liquid::Drop
    def initialize(model, attribute = nil)
      @model     = model
      @attribute = attribute
    end

    attr_reader :model, :attribute

    def class_name
      model.class.name.gsub(/Drop$/, '')
    end

    def errors
      errors = if @model&.instance_variable_get('@object')
                 @model.instance_variable_get('@object').errors
               else
                 ::ActiveModel::Errors.new([])
               end

      ::Scribo::ActiveModel::ErrorsDrop.new errors
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
scribo-1.0.44 app/drops/scribo/form_drop.rb
scribo-1.0.43 app/drops/scribo/form_drop.rb
scribo-1.0.42 app/drops/scribo/form_drop.rb
scribo-1.0.41 app/drops/scribo/form_drop.rb
scribo-1.0.40 app/drops/scribo/form_drop.rb
scribo-1.0.39 app/drops/scribo/form_drop.rb
scribo-1.0.38 app/drops/scribo/form_drop.rb