Module: Blacklight::Document::ActiveModelShim

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Conversion
Included in:
Solr::Document
Defined in:
app/models/concerns/blacklight/document/active_model_shim.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#[](*args) ⇒ Object

accessors for reading attribute



41
42
43
# File 'app/models/concerns/blacklight/document/active_model_shim.rb', line 41

def [] *args
  _source.send :[], *args
end

#_read_attribute(attr) ⇒ Object



45
46
47
# File 'app/models/concerns/blacklight/document/active_model_shim.rb', line 45

def _read_attribute(attr)
  self[attr]
end

#as_json(options = nil) ⇒ Object



49
50
51
# File 'app/models/concerns/blacklight/document/active_model_shim.rb', line 49

def as_json(options = nil)
  _source.as_json(options)
end

#destroyed?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'app/models/concerns/blacklight/document/active_model_shim.rb', line 60

def destroyed?
  false
end

#idObject

Unique ID for the document



35
36
37
# File 'app/models/concerns/blacklight/document/active_model_shim.rb', line 35

def id
  self[self.class.unique_key]
end

#marked_for_destruction?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'app/models/concerns/blacklight/document/active_model_shim.rb', line 68

def marked_for_destruction?
  false
end

#new_record?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'app/models/concerns/blacklight/document/active_model_shim.rb', line 64

def new_record?
  false
end

#persisted?Boolean

ActiveRecord::Persistence method stubs to get non-AR objects to play nice with e.g. Blacklight's bookmarks

Returns:

  • (Boolean)


56
57
58
# File 'app/models/concerns/blacklight/document/active_model_shim.rb', line 56

def persisted?
  true
end

#to_partial_pathObject

#to_partial_path is also defined in Blacklight::Document, but ActiveModel::Conversion (included above) will overwrite that..



75
76
77
# File 'app/models/concerns/blacklight/document/active_model_shim.rb', line 75

def to_partial_path
  'catalog/document'
end