Sha256: 35576227889d3a769caf0caac1acb309dc245d1a0b5119437402b1845a5e7eba

Contents?: true

Size: 1.13 KB

Versions: 16

Compression:

Stored size: 1.13 KB

Contents

module Cell
  # Makes #options available in Cells 3.7, which was removed in favor of state-args.
  # Note that Deprecations are only available for Cell::Rails.
  module Deprecations
    extend ActiveSupport::Concern

    included do
      attr_reader :options
    end


    module ClassMethods
      def build_for(controller, *args)
        build_class_for(controller, *args).
        new(controller, *args)
      end
    end


    def initialize(parent_controller, *args)
      super(parent_controller)  # the real Rails.new.
      setup_backwardibility(*args)
    end

    # Some people still like #options and assume it's a hash.
    def setup_backwardibility(*args)
      @_options = (args.first.is_a?(Hash) and args.size == 1) ? args.first : args
      @options  = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(@_options, "#options is deprecated and was removed in Cells 3.7. Please use state-args.")
    end

    def render_state(state, *args)
      return super(state, *args) if state_accepts_args?(state)
      super(state)  # backward-compat.
    end

    def state_accepts_args?(state)
      method(state).arity != 0
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cells-3.11.3 lib/cell/deprecations.rb
cells-3.11.2 lib/cell/deprecations.rb
cells-3.11.1 lib/cell/deprecations.rb
cells-3.11.0 lib/cell/deprecations.rb
cells-3.10.1 lib/cell/deprecations.rb
cells-3.10.0 lib/cell/deprecations.rb
cells-3.9.1 lib/cell/deprecations.rb
cells-3.9.0 lib/cell/deprecations.rb
cells-3.8.8 lib/cell/deprecations.rb
cells-3.8.7 lib/cell/deprecations.rb
cells-3.8.6 lib/cell/deprecations.rb
cells-3.8.5 lib/cell/deprecations.rb
cells-3.8.4 lib/cell/deprecations.rb
cells-3.8.3 lib/cell/deprecations.rb
cells-3.8.2 lib/cell/deprecations.rb
cells-3.8.1 lib/cell/deprecations.rb