Sha256: b3d65eae5660d661a9dfe9c3c7476873a1bba877e607e8b572630b6398bbb851

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

module Cieloz
  class RequisicaoTid < Requisicao
    module ClassMethods
      def map source, opts={}
        tid = attrs_from source, opts, :tid
        new source: source, opts: opts, tid: tid
      end
    end

    def self.inherited(target)
      target.extend ClassMethods
    end

    attr_accessor :tid

    def attributes
      { tid: @tid, dados_ec: @dados_ec }
    end
  end

  class RequisicaoTidValor < RequisicaoTid
    module ClassMethods
      def map source, opts={}
        tid, valor = attrs_from source, opts, :tid, :valor
        new source: source, opts: opts, tid: tid, valor: valor
      end
    end

    def self.inherited(target)
      target.extend ClassMethods
    end

    attr_reader :valor

    def valor=(val)
      @valor = (val.nil? or val.integer?) ? val : (val * 100).round
    end

    def attributes
      { tid: @tid, dados_ec: @dados_ec, valor: @valor }
    end
  end

  class RequisicaoConsulta < RequisicaoTid ; end
  class RequisicaoAutorizacaoTid < RequisicaoTid ; end

  class RequisicaoCaptura < RequisicaoTidValor ; end
  class RequisicaoCancelamento < RequisicaoTidValor ; end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cieloz-0.0.21 lib/cieloz/requisicao_tid.rb
cieloz-0.0.20 lib/cieloz/requisicao_tid.rb
cieloz-0.0.19 lib/cieloz/requisicao_tid.rb