Sha256: 4b5d3fe0f5b5721b859e213fa9a4c37979346c76096a5fefbbc901bca9487705

Contents?: true

Size: 1.2 KB

Versions: 50

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

class Ibrain::Base < Ibrain::ApplicationRecord
  include ActionView::Helpers::DateHelper

  IGNORE_ATTRIBUTES = %w(id created_at updated_at)

  self.abstract_class = true

  def string_id
    try(:id).try(:to_s)
  end

  scope :graphql_ransack, lambda { |params|
    ransack(params).result
  }

  scope :reverse_scope, lambda {
    order(created_at: :desc)
  }

  scope :ransack_query, lambda { |params, page, per_page = 10|
    ransack(params).
      result.
      page(page).
      per(per_page)
  }

  def cryptor
    ::Ibrain::Encryptor.new
  end

  def created_in_word
    time_ago_in_words(created_at)
  end

  class << self
    # Provides a scope that should be included any time data
    # are fetched with the intention of displaying to the user.
    #
    # Allows individual stores to include any active record scopes or joins
    # when data are displayed.
    def display_includes
      where(nil)
    end

    def paginate(args)
      limit(args[:limit]).offset(args[:offset])
    end

    def adjust_date_for_cdt(datetime)
      datetime.in_time_zone('UTC')
    end

    def permitted_attributes
      column_names.reject { |k| IGNORE_ATTRIBUTES.include?(k) }
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
ibrain-core-0.5.15 app/models/ibrain/base.rb
ibrain-core-0.5.13 app/models/ibrain/base.rb
ibrain-core-0.5.12 app/models/ibrain/base.rb
ibrain-core-0.5.10 app/models/ibrain/base.rb
ibrain-core-0.5.9 app/models/ibrain/base.rb
ibrain-core-0.5.8 app/models/ibrain/base.rb
ibrain-core-0.5.7 app/models/ibrain/base.rb
ibrain-core-0.5.6 app/models/ibrain/base.rb
ibrain-core-0.5.5 app/models/ibrain/base.rb
ibrain-core-0.5.4 app/models/ibrain/base.rb
ibrain-core-0.5.3 app/models/ibrain/base.rb
ibrain-core-0.5.2 app/models/ibrain/base.rb
ibrain-core-0.5.1 app/models/ibrain/base.rb
ibrain-core-0.5.0 app/models/ibrain/base.rb
ibrain-core-0.4.9 app/models/ibrain/base.rb
ibrain-core-0.4.8 app/models/ibrain/base.rb
ibrain-core-0.4.7 app/models/ibrain/base.rb
ibrain-core-0.4.6 app/models/ibrain/base.rb
ibrain-core-0.4.5 app/models/ibrain/base.rb
ibrain-core-0.4.4 app/models/ibrain/base.rb