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.1.2 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.1.1 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.68 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.67 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.66 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.65 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.64 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.63 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.62 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.61 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.60 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.59 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.58 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.57 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.56 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.55 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.54 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.53 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.52 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.51 lib/eco/api/common/people/person_modifier.rb