Module: Card::Model::SaveHelper::SaveHelperHelper

Included in:
Card::Model::SaveHelper
Defined in:
lib/card/model/save_helper/save_helper_helper.rb

Overview

private helper methods for public SaveHelper api

Constant Summary collapse

CARDTYPE_METHOD_REGEXP =
/^(?<method_name>create|ensure)_(?<type>.+?)(?:_card)?$/

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object (private)



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/card/model/save_helper/save_helper_helper.rb', line 20

def method_missing method, *args
  method_name, cardtype_card = extract_cardtype_from_method_name method
  return super unless method_name

  sargs = standardize_args(*args).merge(type_id: cardtype_card.id)
  if method_name == "ensure"
    Card.ensure sargs
  else
    send "#{method_name}_card", sargs
  end
end