Class: Administrate::Field::Deferred

Inherits:
Object
  • Object
show all
Defined in:
lib/administrate/field/deferred.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @deferred_class = deferred_class
  @options = options
end

Instance Attribute Details

#deferred_classObject (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

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/administrate/field/deferred.rb', line 11

def options
  @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 &&
    options == other.options
end

#new(*args) ⇒ Object



13
14
15
16
# File 'lib/administrate/field/deferred.rb', line 13

def new(*args)
  new_options = args.last.respond_to?(:merge) ? args.pop : {}
  deferred_class.new(*args, options.merge(new_options))
end

#permitted_attribute(attr, _options = nil) ⇒ Object



32
33
34
35
# File 'lib/administrate/field/deferred.rb', line 32

def permitted_attribute(attr, _options = nil)
  options.fetch(:foreign_key,
    deferred_class.permitted_attribute(attr, options))
end

#searchable?Boolean

Returns:



24
25
26
# File 'lib/administrate/field/deferred.rb', line 24

def searchable?
  options.fetch(:searchable, deferred_class.searchable?)
end

#searchable_fieldObject



28
29
30
# File 'lib/administrate/field/deferred.rb', line 28

def searchable_field
  options.fetch(:searchable_field)
end