dnesteryuk/site_prism.vcr

View on GitHub
lib/site_prism_vcr/mixins/element.rb

Summary

Maintainability
A
0 mins
Test Coverage
module SPV
  module Mixins
    module Element
      def element_with_vcr(element_name, *args, &block)
        element element_name, *args

        link_vcr_with_element(element_name, &block)
      end

      def link_vcr_with_element(element_name, &block)
        origin_element_name = "origin_#{element_name}"

        alias_method origin_element_name, element_name

        define_method element_name.to_s do
          elem = public_send(origin_element_name)

          SPV::Element.new(elem, self, &block)
        end
      end
    end
  end
end