module ShoppingCart
  module ApplicationHelper
  	def method_missing(method, *args, &block)
      if (method.to_s.end_with?('_path') || method.to_s.end_with?('_url')) && main_app.respond_to?(method)
        main_app.send(method, *args)
      else
        super
      end
    end

    def full_title(title)
	    f_title = "Geek Books"
	    if (title.empty?)
	      f_title
	    else
	      "#{f_title} | #{title}"
	    end
	  end 
	  
	  def isnull(object, meth1, meth2)
	    raise 'Object should be present' unless object.present?
	    if (new_object = object.send(meth1)).present?
	      new_object
	    else
	      object.send(meth2)
	    end
	  end
	  
	  def hide_card(card)
	    card[0..3] + '****' + card[-3] + card[-2] + card[-1]
	  end
  end
end
