Skip to content

Instantly share code, notes, and snippets.

@ornerymoose
Created May 8, 2012 17:58
Show Gist options
  • Select an option

  • Save ornerymoose/2638002 to your computer and use it in GitHub Desktop.

Select an option

Save ornerymoose/2638002 to your computer and use it in GitHub Desktop.
Not the dryest by any means but gets the job done
class BulkOrder
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :amex, :billing_address, :billing_city, :billing_company,
:billing_email_address, :billing_fax, :billing_phone,
:billing_state, :billing_zip, :bulk_order_date, :check,
:corporate_gifting, :corporate_loyalty_program, :credit_card,
:customer_number, :discover, :employee_incentives, :gift_card,
:initial_total, :mc, :non_profit_fundraiser, :overall_total,
:processing_fee, :quantity, :requested_brands, :shipping_address,
:shipping_city, :shipping_company, :shipping_fee, :shipping_name,
:shipping_phone, :shipping_state, :shipping_zip, :subtotal, :unit_cost, :visa
def initialize (
amex="", billing_address="", billing_city="", billing_company="", billing_email_address="",
billing_fax="", billing_phone="", billing_state="", billing_zip="", bulk_order_date="",
check="", corporate_gifting="", corporate_loyalty_program="", credit_card="", customer_number="",
discover="", employee_incentives="", gift_card="", initial_total="", mc="", non_profit_fundraiser="",
overall_total="", processing_fee="", quantity="", requested_brands="", shipping_address="",
shipping_city="", shipping_company="", shipping_fee="", shipping_name="", shipping_phone="",
shipping_state="", shipping_zip="", subtotal="", unit_cost="", visa="")
@amex = amex
@billing_address = billing_address
@billing_city = billing_city
@billing_company = billing_company
@billing_email_address = billing_email_address
@billing_fax = billing_fax
@billing_phone = billing_phone
@billing_phone = billing_phone
@billing_zip = billing_zip
@bulk_order_date = bulk_order_date
@check = check
@corporate_gifting = corporate_gifting
@corporate_loyalty_program = corporate_loyalty_program
@credit_card = credit_card
@customer_number = customer_number
@discover
@employee_incentives = discover
@gift_card = gift_card
@initial_total = initial_total
@mc = mc
@non_profit_fundraiser = non_profit_fundraiser
@overall_total = overall_total
@processing_fee = processing_fee
@quantity = quantity
@requested_brands = requested_brands
@shipping_address = shipping_address
@shipping_city = shipping_city
@shipping_company = shipping_company
@shipping_fee = shipping_fee
@shipping_name = shipping_name
@shipping_phone = shipping_phone
@shipping_state = shipping_state
@shipping_zip = shipping_zip
@subtotal = subtotal
@unit_cost = unit_cost
@visa = visa
end
def persisted?
false
end
end
@krisleech
Copy link

Posting on an old gist, but to get rid of all those instance var's try Virtus: https://github.com/solnic/virtus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment