Class: Corzinus::Checkout::AddressStep

Inherits:
Rectify::Command
  • Object
show all
Includes:
AddressableAttrubutes
Defined in:
app/commands/corzinus/checkout/address_step.rb

Direct Known Subclasses

UpdateAddress

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AddressableAttrubutes

#address_by_params, #addresses_by_model, #addresses_by_params, #set_countries

Constructor Details

#initialize(options) ⇒ AddressStep

Returns a new instance of AddressStep.



8
9
10
11
12
13
# File 'app/commands/corzinus/checkout/address_step.rb', line 8

def initialize(options)
  @addressable = options[:order]
  @params = options[:params]
  @addresses = addresses_by_params(params[:order],
                                   params[:use_base_address])
end

Instance Attribute Details

#addressableObject (readonly)

Returns the value of attribute addressable.



6
7
8
# File 'app/commands/corzinus/checkout/address_step.rb', line 6

def addressable
  @addressable
end

#addressesObject (readonly)

Returns the value of attribute addresses.



6
7
8
# File 'app/commands/corzinus/checkout/address_step.rb', line 6

def addresses
  @addresses
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'app/commands/corzinus/checkout/address_step.rb', line 6

def params
  @params
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
# File 'app/commands/corzinus/checkout/address_step.rb', line 15

def call
  if attributes_valid? && update_addressable
    broadcast(:valid)
  else
    broadcast :invalid, expose_addresses
  end
end