Sha256: e9b68ae0cbd667348d8b9e30a944f4901e53a46d920aec6dce8a978f1ece4874
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
require "active_support/core_ext/module/delegation" module Administrate module Field class Deferred def initialize(deferred_class, options = {}) @deferred_class = deferred_class @options = options end attr_reader :deferred_class, :options def new(*args) new_options = args.last.respond_to?(:merge) ? args.pop : {} deferred_class.new(*args, options.merge(new_options)) end def ==(other) other.respond_to?(:deferred_class) && deferred_class == other.deferred_class && options == other.options end def getter options.fetch(:getter, nil) end def associative? deferred_class.associative? end def eager_load? deferred_class.eager_load? end def searchable? if options.key?(:getter) false else options.fetch(:searchable, deferred_class.searchable?) end end def searchable_field Administrate.deprecator.warn( "searchable_field is deprecated, use searchable_fields instead" ) options.fetch(:searchable_field) end def searchable_fields if options.key?(:searchable_field) [searchable_field] else options.fetch(:searchable_fields) end end def permitted_attribute(attr, opts = {}) if options.key?(:foreign_key) Administrate.warn_of_deprecated_option(:foreign_key) options.fetch(:foreign_key) else deferred_class.permitted_attribute(attr, options.merge(opts)) end end delegate :html_class, to: :deferred_class end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
administrate-1.0.0.beta3 | lib/administrate/field/deferred.rb |
administrate-1.0.0.beta2 | lib/administrate/field/deferred.rb |