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.0.30 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.29 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.28 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.27 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.26 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.25 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.24 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.23 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.22 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.21 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.19 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.18 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.17 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.16 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.15 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.14 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.13 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.12 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.11 lib/eco/api/common/people/person_modifier.rb
eco-helpers-2.0.10 lib/eco/api/common/people/person_modifier.rb