Sha256: 58a96d9d52e9b4d761ca770807b4eb467633e6bbdcaf05dae812e7000a46ca91

Contents?: true

Size: 804 Bytes

Versions: 6

Compression:

Stored size: 804 Bytes

Contents

module IamHelper
  include Iam::AuthorizationProvider::Factory.current_provider

  [:account, :role].each do |type|
    define_method "#{type}_name" do |instance|
      extract_attributes(instance, type).join ' '
    end
  end

  def extract_attributes(instance, type)
    Iam::Configuration[type][:attributes].map do |attribute|
      instance.public_send attribute
    end
  end

  def account_samples
    role_class = Iam::Configuration[:role][:class].constantize
    account_class = Iam::Configuration[:account][:class].constantize

    role_class.all.inject({}) do |account_groups, role|
      account_group = account_class.where(role_class.to_s.foreign_key => role.id).order(:id).limit(Iam::Configuration[:accounts_for_each_role])
      account_groups.merge role => account_group
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
iam-0.3.3 app/helpers/iam_helper.rb
iam-0.3.2 app/helpers/iam_helper.rb
iam-0.3.1 app/helpers/iam_helper.rb
iam-0.3.0 app/helpers/iam_helper.rb
iam-0.2.2 app/helpers/iam_helper.rb
iam-0.2.1 app/helpers/iam_helper.rb