Sha256: f66b4e49b45a1507647a35f6891cb810724cdfb74c4061c5c5d4f1fd9e9002fa

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

class Gon
  class Global < Gon
    class << self

      def all_variables
        @global_vars || {}
      end

      def clear
        @global_vars = {}
      end

      def inspect
        'Gon::Global'
      end

      def rabl(*args)
        unless Gon.constants.include?(:Rabl)
          raise "Possible wrong require order problem - try to add `gem 'rabl'` before `gem 'gon'` in your Gemfile"
        end
        data, options = Gon::Rabl.handler(args, true)

        store_builder_data 'rabl', data, options
      end

      def jbuilder(*args)
        unless Gon.constants.include?(:Jbuilder)
          raise "Possible wrong require order problem - try to add `gem 'jbuilder'` before `gem 'gon'` in your Gemfile"
        end
        data, options = Gon::Jbuilder.handler(args, true)

        store_builder_data 'jbuilder', data, options
      end

      private

      def get_variable(name)
        @global_vars ||= {}
        @global_vars[name]
      end

      def set_variable(name, value)
        @global_vars ||= {}
        @global_vars[name] = value
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gon-4.0.3 lib/gon/global.rb
gon-4.0.2 lib/gon/global.rb
gon-4.0.1 lib/gon/global.rb
gon-4.0.0 lib/gon/global.rb