Module: ActiveInteraction::ActiveRecordable

Included in:
Base
Defined in:
lib/active_interaction/concerns/active_recordable.rb

Overview

Implement the minimal ActiveRecord interface.

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

#column_for_attribute(name) ⇒ FilterColumn?

Returns the column object for the named filter.

Examples:

class Interaction < ActiveInteraction::Base
  string :email, default: nil

  def execute; end
end

Interaction.new.column_for_attribute(:email)
# => #<ActiveInteraction::FilterColumn:0x007faebeb2a6c8 @type=:string>

Interaction.new.column_for_attribute(:not_a_filter)
# => nil

Parameters:

  • name (Symbol)

    The name of a filter.

Returns:

Since:

  • 1.2.0



29
30
31
32
# File 'lib/active_interaction/concerns/active_recordable.rb', line 29

def column_for_attribute(name)
  filter = self.class.filters[name]
  FilterColumn.intern(filter.database_column_type) if filter
end

#has_attribute?(name) ⇒ Boolean

Returns true if a filter of that name exists.

Examples:

class Interaction < ActiveInteraction::Base
  string :email, default: nil

  def execute; end
end

Interaction.new.has_attribute?(:email)
# => true

Interaction.new.has_attribute?(:not_a_filter)
# => false

Parameters:

  • name (String, Symbol)

    The name of a filter.

Returns:

  • (Boolean)

Since:

  • 1.5.0



54
55
56
# File 'lib/active_interaction/concerns/active_recordable.rb', line 54

def has_attribute?(name) # rubocop:disable Style/PredicateName
  self.class.filters.key?(name.to_sym)
end