Module: RubyPsigate::HashVariables
- Included in:
- Address, CreditCard, Item, Order, RecurringCharge, RecurringItem
- Defined in:
- lib/ruby_psigate/hash_variables.rb
Overview
In your class, you can define the instance variables you want to wrap in a hash output
Usage:
hashable :billing, [:name, :address, :city, :state, :country, :zipcode]
What this will do is create a hash like this when you call the class’ instance #to_hash(:billing) { :name => “Bob”, :address => “1234 West St”, :city => “North York”, :state => “NY”, :country => “USA”, zipcode => “12345”}
If you don’t specify a “name”, you can simply call #to_hash:
hashable [:name, :address, :city, :state, :country, :zipcode] instance#to_hash will yield the same output as above
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
18 19 20 21 |
# File 'lib/ruby_psigate/hash_variables.rb', line 18 def self.included(klass) klass.extend ClassMethods klass.send(:include, InstanceMethods) end |