Class: Administrate::Field::Deferred
- Inherits:
-
Object
- Object
- Administrate::Field::Deferred
- Defined in:
- lib/administrate/field/deferred.rb
Instance Attribute Summary collapse
-
#deferred_class ⇒ Object
readonly
Returns the value of attribute deferred_class.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #associative? ⇒ Boolean
- #eager_load? ⇒ Boolean
- #getter ⇒ Object
-
#initialize(deferred_class, options = {}) ⇒ Deferred
constructor
A new instance of Deferred.
- #new(*args) ⇒ Object
- #permitted_attribute(attr, opts = {}) ⇒ Object
- #searchable? ⇒ Boolean
- #searchable_field ⇒ Object
- #searchable_fields ⇒ Object
Constructor Details
#initialize(deferred_class, options = {}) ⇒ Deferred
Returns a new instance of Deferred.
6 7 8 9 |
# File 'lib/administrate/field/deferred.rb', line 6 def initialize(deferred_class, = {}) @deferred_class = deferred_class @options = end |
Instance Attribute Details
#deferred_class ⇒ Object (readonly)
Returns the value of attribute deferred_class.
11 12 13 |
# File 'lib/administrate/field/deferred.rb', line 11 def deferred_class @deferred_class end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/administrate/field/deferred.rb', line 11 def @options end |
Instance Method Details
#==(other) ⇒ Object
18 19 20 21 22 |
# File 'lib/administrate/field/deferred.rb', line 18 def ==(other) other.respond_to?(:deferred_class) && deferred_class == other.deferred_class && == other. end |
#associative? ⇒ Boolean
28 29 30 |
# File 'lib/administrate/field/deferred.rb', line 28 def associative? deferred_class.associative? end |
#eager_load? ⇒ Boolean
32 33 34 |
# File 'lib/administrate/field/deferred.rb', line 32 def eager_load? deferred_class.eager_load? end |
#getter ⇒ Object
24 25 26 |
# File 'lib/administrate/field/deferred.rb', line 24 def getter .fetch(:getter, nil) end |
#new(*args) ⇒ Object
13 14 15 16 |
# File 'lib/administrate/field/deferred.rb', line 13 def new(*args) = args.last.respond_to?(:merge) ? args.pop : {} deferred_class.new(*args, .merge()) end |
#permitted_attribute(attr, opts = {}) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/administrate/field/deferred.rb', line 59 def permitted_attribute(attr, opts = {}) if .key?(:foreign_key) Administrate.warn_of_deprecated_option(:foreign_key) .fetch(:foreign_key) else deferred_class.permitted_attribute(attr, .merge(opts)) end end |
#searchable? ⇒ Boolean
36 37 38 39 40 41 42 |
# File 'lib/administrate/field/deferred.rb', line 36 def searchable? if .key?(:getter) false else .fetch(:searchable, deferred_class.searchable?) end end |
#searchable_field ⇒ Object
44 45 46 47 48 49 |
# File 'lib/administrate/field/deferred.rb', line 44 def searchable_field Administrate.deprecator.warn( "searchable_field is deprecated, use searchable_fields instead" ) .fetch(:searchable_field) end |
#searchable_fields ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/administrate/field/deferred.rb', line 51 def searchable_fields if .key?(:searchable_field) [searchable_field] else .fetch(:searchable_fields) end end |