Class: Lims::Core::Persistence::Search::SearchSequelPersistor

Inherits:
SearchPersistor show all
Includes:
Lims::Core::Persistence::Sequel::Persistor
Defined in:
lib/lims-core/persistence/search/search_sequel_persistor.rb

Constant Summary

Constants included from Lims::Core::Persistence::Sequel::Filters

COMPARISON_OPERATORS

Constants inherited from SearchPersistor

Model

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Lims::Core::Persistence::Sequel::Persistor

#bulk_insert, #bulk_load, #count, #dataset, included, #initialize, #table_name

Methods included from Lims::Core::Persistence::Sequel::Filters

#add_comparison_filter, #comparison_filter, #multi_criteria_filter

Methods inherited from SearchPersistor

#parents

Methods inherited from Persistor

#[], #bind_state_to_id, #bind_state_to_resource, #bulk_delete, #bulk_delete_raw, #bulk_insert, #bulk_retrieve, #bulk_update, #children, #count, #deletable_children, #deletable_parents, #dirty_key_for, #for_each_in_slice, #id_for, #ids_for, inherited, #initialize, #invalid_resource?, #load_children, #model, #new_from_attributes, #new_object, #object_for, #on_object_load, #parents, #parents_for_attributes, #purge_invalid_object, register_model, #retrieve, #slice, #state_for, #state_for_id

Constructor Details

This class inherits a constructor from Lims::Core::Persistence::Sequel::Persistor

Class Method Details

+ (Object) table_name



14
15
16
# File 'lib/lims-core/persistence/search/search_sequel_persistor.rb', line 14

def self.table_name
  :searches
end

Instance Method Details

- (Object) filter_attributes_on_load(attributes)



18
19
20
21
22
23
24
# File 'lib/lims-core/persistence/search/search_sequel_persistor.rb', line 18

def filter_attributes_on_load(attributes)
  {
    :description => attributes[:description],
    :model => constant(attributes[:model]),
    :filter => Persistence.const_get(attributes[:filter_type]).new(Marshal.load(attributes[:filter_parameters]))
  }
end

- (Object) filter_attributes_on_save(attributes, *args)



25
26
27
28
29
30
31
32
33
# File 'lib/lims-core/persistence/search/search_sequel_persistor.rb', line 25

def filter_attributes_on_save(attributes, *args)
  filter = attributes[:filter]
  {
    :description => attributes[:description],
    :model => attributes[:model].name,
    :filter_type => filter.class.name.split('::').last,
    :filter_parameters => Marshal.dump(filter.attributes)
  }
end