Sha256: 0cba8eeae74f6ed75c07e237fa13520f2b6057a7fc2935b12cb165ac92e6b804

Contents?: true

Size: 1.67 KB

Versions: 196

Compression:

Stored size: 1.67 KB

Contents

module Eco
  module API
    module Common
      module People
        class PersonModifier < Eco::Language::Models::Modifier

          WITH_DETAILS = [:contact, :details, :with_details, :schema, :with_schema]
          NO_DETAILS   = [:no_details, :only_account]

          WITH_ACCOUNT = [:user, :account, :with_account]
          NO_ACCOUNT   = [:no_account, :only_details]

          INTERNAL_PERSON = [:internal, :v0]
          EXTERNAL_PERSON = [:external, :v1]

          def reset_add_account
            self < self.mode - (WITH_ACCOUNT | NO_ACCOUNT)
          end

          def no_details
            self.push(:no_details)
          end
          
          def add_account?
            mode.any? { |m| WITH_ACCOUNT.include?(m) }
          end

          def no_account?
            mode.any? { |m| NO_ACCOUNT.include?(m) }
          end

          def add_details?
            mode.any? { |m| WITH_DETAILS.include?(m) }
          end

          def no_details?
            mode.any? { |m| NO_DETAILS.include?(m) }
          end

          def internal?
            bool = mode.any? { |m| INTERNAL_PERSON.include?(m) }
            bool || !external?
          end

          def external?
            mode.any? { |m| EXTERNAL_PERSON.include?(m) }
          end

          protected

          def resolve_mode
            modifiers = self.to_a
            modifiers = resolve(modifiers, WITH_DETAILS | NO_DETAILS)
            modifiers = resolve(modifiers, WITH_ACCOUNT | NO_ACCOUNT)
            modifiers = resolve(modifiers, INTERNAL_PERSON | EXTERNAL_PERSON)
            modifiers
          end
        end
      end
    end
  end
end

Version data entries

196 entries across 196 versions & 1 rubygems

Version Path
eco-helpers-2.4.4 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.4.3 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.4.2 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.3.3 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.3.2 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.2.5 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.2.4 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.2.3 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.2.2 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.2.1 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.12 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.11 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.10 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.9 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.8 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.7 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.6 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.5 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.4 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.3 lib/eco/api/common/people/person_modifier.rb