Sha256: 69b48808d3be633b0ea39d68bcaa1eea4bf1e00e500efbf339d0492cade7d8a2

Contents?: true

Size: 542 Bytes

Versions: 24

Compression:

Stored size: 542 Bytes

Contents

module Pacioli
  class CompanyValidator
    attr_accessor :company

    def self.for(company)
      validator = new
      validator.company = company
      validator
    end

    def execute
      validate_accounts
    end

    def validate_accounts
      accounts = self.company.accounts.map(&:name)
      raise Pacioli::CompanyAccountException, "The company has multiple accounts with the same name: '#{accounts.detect{ |e| accounts.count(e) > 1 }}' already exists" unless accounts.detect{ |e| accounts.count(e) > 1 }.nil?
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
pacioli-0.0.29 lib/pacioli/validations/company_validator.rb
pacioli-0.0.28 lib/pacioli/validations/company_validator.rb
pacioli-0.0.27 lib/pacioli/validations/company_validator.rb
pacioli-0.0.26 lib/pacioli/validations/company_validator.rb
pacioli-0.0.25 lib/pacioli/validations/company_validator.rb
pacioli-0.0.24 lib/pacioli/validations/company_validator.rb
pacioli-0.0.23 lib/pacioli/validations/company_validator.rb
pacioli-0.0.22 lib/pacioli/validations/company_validator.rb
pacioli-0.0.21 lib/pacioli/validations/company_validator.rb
pacioli-0.0.20 lib/pacioli/validations/company_validator.rb
pacioli-0.0.19 lib/pacioli/validations/company_validator.rb
pacioli-0.0.18 lib/pacioli/validations/company_validator.rb
pacioli-0.0.17 lib/pacioli/validations/company_validator.rb
pacioli-0.0.16 lib/pacioli/validations/company_validator.rb
pacioli-0.0.15 lib/pacioli/validations/company_validator.rb
pacioli-0.0.14 lib/pacioli/validations/company_validator.rb
pacioli-0.0.13 lib/pacioli/validations/company_validator.rb
pacioli-0.0.12 lib/pacioli/validations/company_validator.rb
pacioli-0.0.11 lib/pacioli/validations/company_validator.rb
pacioli-0.0.10 lib/pacioli/validations/company_validator.rb