Sha256: 658f1546f2f5fa85fa08bf19caefdc56cc7e59b28d7b2218b385ffbc472276f6

Contents?: true

Size: 843 Bytes

Versions: 29

Compression:

Stored size: 843 Bytes

Contents

class Eco::API::Common::People::DefaultParsers::PolicyGroupsParser < Eco::API::Common::Loaders::Parser
  attribute "policy_group_ids"

  def parser(hash, deps)
    policy_group_ids = []
    if policy_ids = hash["policy_group_ids"]
      policy_group_ids = policy_ids.split("|").map do |name|
        policy_groups.to_id(name&.downcase.strip)
      end.compact
    end
    policy_group_ids.empty?? default_id : policy_group_ids.join("|")
  end

  def serializer(person, deps)
    ids   = person&.account&.policy_group_ids || []
    ids.map do |id|
      policy_groups.to_name(id)
    end.compact.join("|")
  end

  private

  def policy_groups
    @policy_groups ||= ASSETS.config.policy_groups
  end

  def default_id
    @default_id    ||= policy_groups.to_id(ASSETS.config.people.default_usergroup)
  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
eco-helpers-2.0.16 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.15 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.14 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.13 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.12 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.11 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.10 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.9 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.8 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.7 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.6 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.5 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.4 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.3 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-2.0.2 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-1.5.15 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-1.5.14 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-1.5.13 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-1.5.12 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
eco-helpers-1.5.11 lib/eco/api/common/people/default_parsers/policy_groups_parser.rb