Sha256: 0d86a03aa46200bfc6f458036b279d7fd0cb296c88f38e4aca09f2314bb94606

Contents?: true

Size: 1.56 KB

Versions: 24

Compression:

Stored size: 1.56 KB

Contents

$cornucopia_element_extension_installed = false unless defined? $cornucopia_element_extension_installed

if Object.const_defined?("SitePrism") &&
    ::SitePrism.const_defined?("Page") &&
    !$cornucopia_element_extension_installed
  module ::SitePrism
    class Page
      include Cornucopia::SitePrism::ElementExtensions

      ::Capybara::Session::DSL_METHODS.each do |method|
        alias_method "__cornucopia_orig_#{method}".to_sym, method

        define_method method do |*args, &block|
          if @__corunucopia_base_node
            @__corunucopia_base_node.send method, *args, &block
          else
            send "__cornucopia_orig_#{method}", *args, &block
          end
        end
      end
    end
  end
end

if Object.const_defined?("SitePrism") &&
    ::SitePrism.const_defined?("Section") &&
    !$cornucopia_element_extension_installed
  $cornucopia_element_extension_installed = true

  module ::SitePrism
    class Section
      include Cornucopia::SitePrism::ElementExtensions

      alias_method :__corunucopia_orig_intialize, :initialize
      def initialize(*args)
        __corunucopia_orig_intialize(*args)

        self.owner_node = args[0].owner_node
      end

      ::Capybara::Session::DSL_METHODS.each do |method|
        alias_method "__cornucopia_orig_#{method}".to_sym, method

        define_method method do |*args, &block|
          if @__corunucopia_base_node
            @__corunucopia_base_node.send method, *args, &block
          else
            send "__cornucopia_orig_#{method}", *args, &block
          end
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
cornucopia-0.1.40 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.39 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.38 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.37 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.36 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.35 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.34 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.33 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.32 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.31 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.30 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.29 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.28 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.26 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.25 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.24 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.23 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.22 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.21 lib/cornucopia/site_prism/install_element_extensions.rb
cornucopia-0.1.20 lib/cornucopia/site_prism/install_element_extensions.rb