Module: CheddargetterClientRails::ClassMethods
- Defined in:
- lib/cheddargetter_client_rails.rb
Instance Method Summary collapse
- #customer_code_column ⇒ Object
- #customer_code_column=(column) ⇒ Object
- #has_subscription(args = {}) ⇒ Object
- #responds_to_customer_code_column? ⇒ Boolean
- #shared_columns ⇒ Object
- #shared_columns=(columns) ⇒ Object
Instance Method Details
#customer_code_column ⇒ Object
135 136 137 |
# File 'lib/cheddargetter_client_rails.rb', line 135 def customer_code_column @customer_code_column end |
#customer_code_column=(column) ⇒ Object
139 140 141 |
# File 'lib/cheddargetter_client_rails.rb', line 139 def customer_code_column=(column) @customer_code_column = column end |
#has_subscription(args = {}) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/cheddargetter_client_rails.rb', line 103 def has_subscription(args = {}) self.class.send(:attr_accessor, :has_subscription_options) self. = args self.customer_code_column = args.delete(:customerCode) || :id raise ArgumentError.new("Record does not respond to #{customer_code_column.to_s}.") if !responds_to_customer_code_column? shared = {} shared[:email] = args.delete(:email) || :email shared[:firstName] = args.delete(:firstName) || :first_name shared[:lastName] = args.delete(:lastName) || :last_name shared[:planCode] = args.delete(:planCode) || :plan_code args.each do |key, value| shared[key] = value end self.shared_columns = shared attr_accessor :skip_cheddargetter attr_accessible :subscription validate :validate_subscription after_create :create_subscription before_destroy :destroy_subscription after_save :update_subscription end |
#responds_to_customer_code_column? ⇒ Boolean
130 131 132 133 |
# File 'lib/cheddargetter_client_rails.rb', line 130 def responds_to_customer_code_column? self.instance_methods.include?(customer_code_column.to_sym) || self.column_names.include?(customer_code_column.to_s) end |
#shared_columns ⇒ Object
143 144 145 |
# File 'lib/cheddargetter_client_rails.rb', line 143 def shared_columns @shared_columns end |
#shared_columns=(columns) ⇒ Object
147 148 149 |
# File 'lib/cheddargetter_client_rails.rb', line 147 def shared_columns=(columns) @shared_columns = columns end |