Class: Garbanzo::Address
- Inherits:
-
Object
- Object
- Garbanzo::Address
- Defined in:
- lib/garbanzo/address.rb
Constant Summary collapse
- ATTRIBUTES =
[ :first_name, :last_name, :company, :address1, :address2, :city, :state, :zip, :country ]
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Address
constructor
A new instance of Address.
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Address
Returns a new instance of Address.
17 18 19 20 21 |
# File 'lib/garbanzo/address.rb', line 17 def initialize( = {}) .each do |attribute, value| public_send("#{attribute}=", value) end end |
Instance Method Details
#to_h ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/garbanzo/address.rb', line 27 def to_h ATTRIBUTES.reduce({}) do |hash, attribute| value = public_send(attribute) hash.merge!(attribute => value) if value hash end end |
#valid? ⇒ Boolean
23 24 25 |
# File 'lib/garbanzo/address.rb', line 23 def valid? first_name.to_s != '' && last_name.to_s != '' end |