Sha256: 548689c40d15598b01af06d574c5a99d74faa6db7a62b5d3c528b56d138245de

Contents?: true

Size: 744 Bytes

Versions: 45

Compression:

Stored size: 744 Bytes

Contents

# Author::    Ondřej Ezr  (mailto:oezr@msp.justice.cz)
# Copyright:: Copyright (c) 2018 Ministry of Justice
# License::   Distributes under license Open Source Licence pro Veřejnou Správu a Neziskový Sektor v.1

module AzaharaSchemaCurrency
  class CurrencyAttribute < AzaharaSchema::Attribute

    def initialize(model, name, type='currency', **options)
      super(model, name, type)
      @options = options
    end

    def currency_code_col
      @options[:currency_code_method] || 'currency_code'
    end

    def currency_code(entity)
      entity.try(currency_code_col)
    end

    def value(record)
      val = super(record)
      val = BigDecimal(val.to_s.presence || 0) unless val.is_a?(BigDecimal)
      val
    end

  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
egov_utils-1.5.0.alpha16 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha15 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha14 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha13 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha12 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha11 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha10 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha9 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha8 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha7 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha6 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha5 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha4 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.4.5 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.4.4 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha3 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha2 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.5.0.alpha1 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.4.3 lib/azahara_schema_currency/currency_attribute.rb
egov_utils-1.4.2 lib/azahara_schema_currency/currency_attribute.rb