Class: BrNfe::ActiveModelBase
- Inherits:
-
Object
- Object
- BrNfe::ActiveModelBase
- Includes:
- ActiveModel::Model, BrNfe::ActiveModel::Associations
- Defined in:
- lib/br_nfe/active_model_base.rb
Direct Known Subclasses
Base, CondicaoPagamento, Endereco, Person, Product::Evento::Base, Product::Gateway::Base, Product::Nfe::AdicaoImportacao, Product::Nfe::Cobranca::Duplicata, Product::Nfe::Cobranca::Fatura, Product::Nfe::Cobranca::Pagamento, Product::Nfe::DeclaracaoImportacao, Product::Nfe::DetalheExportacao, Product::Nfe::Item, Product::Nfe::ItemTax::Cofins, Product::Nfe::ItemTax::CofinsSt, Product::Nfe::ItemTax::Icms, Product::Nfe::ItemTax::IcmsUfDestino, Product::Nfe::ItemTax::Importacao, Product::Nfe::ItemTax::Ipi, Product::Nfe::ItemTax::Issqn, Product::Nfe::ItemTax::Pis, Product::Nfe::ItemTax::PisSt, Product::Nfe::ProcessoReferencia, Product::Nfe::Transporte::Base, Product::Nfe::Transporte::Veiculo, Product::Nfe::Transporte::Volume, Product::NotaFiscal, Product::Response::Base, Product::Response::Build::Base, Product::Response::Event, Service::Item, Service::Response::Build::Base, Service::Response::Default, Service::Response::NotaFiscal, Service::Rps
Instance Attribute Summary collapse
-
#reference ⇒ Object
Utilizado para referenciar o objeto que utiliza a informação.
Instance Method Summary collapse
- #assign_attributes(attributes) ⇒ Object
- #default_values ⇒ Object
-
#initialize(attributes = {}) {|_self| ... } ⇒ ActiveModelBase
constructor
A new instance of ActiveModelBase.
Constructor Details
#initialize(attributes = {}) {|_self| ... } ⇒ ActiveModelBase
Returns a new instance of ActiveModelBase.
16 17 18 19 20 |
# File 'lib/br_nfe/active_model_base.rb', line 16 def initialize(attributes = {}) attributes = default_values.merge!(attributes) assign_attributes(attributes) yield self if block_given? end |
Instance Attribute Details
#reference ⇒ Object
Utilizado para referenciar o objeto que utiliza a informação. Setado automaticamnete no has_one e has_many; Exemplo:
~$ endereco = Endereco.new
~$ pessoa = Pessoa.new(endereco: endereco)
~$ endereco.reference
~$ => pessoa
14 15 16 |
# File 'lib/br_nfe/active_model_base.rb', line 14 def reference @reference end |
Instance Method Details
#assign_attributes(attributes) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/br_nfe/active_model_base.rb', line 22 def assign_attributes(attributes) attributes ||= {} attributes.each do |name, value| send("#{name}=", value) end end |
#default_values ⇒ Object
29 30 31 |
# File 'lib/br_nfe/active_model_base.rb', line 29 def default_values {} end |