Class: BrNfe::ActiveModelBase

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/br_nfe/active_model_base.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) {|_self| ... } ⇒ ActiveModelBase

Returns a new instance of ActiveModelBase.

Yields:

  • (_self)

Yield Parameters:



5
6
7
8
9
# File 'lib/br_nfe/active_model_base.rb', line 5

def initialize(attributes = {})
	attributes = default_values.merge!(attributes)
	assign_attributes(attributes)
	yield self if block_given?
end

Instance Method Details

#assign_attributes(attributes) ⇒ Object



11
12
13
14
15
16
# File 'lib/br_nfe/active_model_base.rb', line 11

def assign_attributes(attributes)
	attributes ||= {}
	attributes.each do |name, value|
		send("#{name}=", value)
	end
end

#default_valuesObject



18
19
20
# File 'lib/br_nfe/active_model_base.rb', line 18

def default_values
	{}
end