Sha256: a53228bf6fd1db526a682982b2fb0d3047e5b1d1674b743f173f44d01fca0f72

Contents?: true

Size: 1.09 KB

Versions: 21

Compression:

Stored size: 1.09 KB

Contents

module Virtus
  class Builder

    # Context used for building "included" and "extended" hooks
    #
    # @private
    class HookContext
      attr_reader :builder, :config, :attribute_method

      # @api private
      def initialize(builder, config)
        @builder, @config = builder, config
        initialize_attribute_method
      end

      # @api private
      def modules
        modules = builder.extensions
        modules << Model::Constructor    if constructor?
        modules << Model::MassAssignment if mass_assignment?
        modules
      end

      # @api private
      def constructor?
        config.constructor
      end

      # @api private
      def mass_assignment?
        config.mass_assignment
      end

      # @api private
      def finalize?
        config.finalize
      end

      # @api private
      def initialize_attribute_method
        method_options = builder.options

        @attribute_method = lambda do |name, type = nil, options = {}|
          super(name, type, method_options.merge(options))
        end
      end

    end # HookContext

  end # Builder
end # Virtus

Version data entries

21 entries across 19 versions & 5 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/lib/virtus/builder/hook_context.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/lib/virtus/builder/hook_context.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/lib/virtus/builder/hook_context.rb
virtus2-2.1.0 lib/virtus/builder/hook_context.rb
virtus2-2.0.2 lib/virtus/builder/hook_context.rb
virtus2-2.0.1 lib/virtus/builder/hook_context.rb
virtus-2.0.0 lib/virtus/builder/hook_context.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/virtus-1.0.5/lib/virtus/builder/hook_context.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/virtus-1.0.5/lib/virtus/builder/hook_context.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/builder/hook_context.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/builder/hook_context.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/builder/hook_context.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/builder/hook_context.rb
virtus-1.0.5 lib/virtus/builder/hook_context.rb
virtus-1.0.4 lib/virtus/builder/hook_context.rb
virtus-1.0.3 lib/virtus/builder/hook_context.rb
virtus-1.0.2 lib/virtus/builder/hook_context.rb
virtus-1.0.1 lib/virtus/builder/hook_context.rb
virtus-1.0.0 lib/virtus/builder/hook_context.rb
virtus-1.0.0.rc2 lib/virtus/builder/hook_context.rb