Sha256: a856d4aefad18eb65e45154bc76813e2c20e06be3eb71567094cdd3620396924

Contents?: true

Size: 983 Bytes

Versions: 44

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true

class Avo::BaseComponent < ViewComponent::Base
  def has_with_trial(ability)
    ::Avo::App.license.has_with_trial(ability)
  end

  private

  # Figure out what is the corresponding field for this @reflection
  def field
    fields = ::Avo::App.get_resource_by_model_name(@reflection.active_record.name).get_field_definitions
    fields.find { |f| f.id == @reflection.name }
  rescue
    nil
  end

  def relation_resource
    ::Avo::App.get_resource_by_model_name params[:via_resource_class].safe_constantize
  end

  # Get the resource for the resource using the klass attribute so we get the namespace too
  def reflection_resource
    ::Avo::App.get_resource_by_model_name(@reflection.klass.to_s)
  rescue
    nil
  end

  # Get the resource for the resource using the klass attribute so we get the namespace too
  def reflection_parent_resource
    ::Avo::App.get_resource_by_model_name(@reflection.active_record.to_s)
  rescue
    nil
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
avo-2.5.2.pre.2 app/components/avo/base_component.rb
avo-2.5.2.pre.1 app/components/avo/base_component.rb
avo-2.5.1 app/components/avo/base_component.rb
avo-2.5.0 app/components/avo/base_component.rb
avo-2.4.1 app/components/avo/base_component.rb
avo-2.4.0 app/components/avo/base_component.rb
avo-2.3.1.pre.6 app/components/avo/base_component.rb
avo-2.3.1.pre.5 app/components/avo/base_component.rb
avo-2.3.1.pre.4 app/components/avo/base_component.rb
avo-2.3.1.pre.3 app/components/avo/base_component.rb
avo-2.3.1.pre.2 app/components/avo/base_component.rb
avo-2.3.1.pre.1 app/components/avo/base_component.rb
avo-2.3.0 app/components/avo/base_component.rb
avo-2.2.2 app/components/avo/base_component.rb
avo-2.2.1 app/components/avo/base_component.rb
avo-2.2.0 app/components/avo/base_component.rb
avo-2.1.2.pre2 app/components/avo/base_component.rb
avo-2.1.2.pre1 app/components/avo/base_component.rb
avo-1.25.1 app/components/avo/base_component.rb
avo-2.1.1 app/components/avo/base_component.rb