discerner 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/app/views/discerner/export_parameters/index.html.haml +8 -8
  4. data/app/views/discerner/parameters/_values_autocompleter.html.haml +18 -18
  5. data/app/views/discerner/parameters/values.html.haml +1 -1
  6. data/app/views/discerner/searches/_form.html.haml +6 -6
  7. data/app/views/discerner/searches/_form_combined_searches.html.haml +4 -4
  8. data/app/views/discerner/searches/_form_controls.html.haml +3 -3
  9. data/app/views/discerner/searches/_form_header.html.haml +6 -6
  10. data/app/views/discerner/searches/_form_search_parameters.html.haml +4 -4
  11. data/app/views/discerner/searches/_list.html.haml +4 -4
  12. data/app/views/discerner/searches/_search_combination_fields.html.haml +4 -4
  13. data/app/views/discerner/searches/_search_parameter_fields.html.haml +15 -15
  14. data/app/views/discerner/searches/_search_parameter_value_fields.html.haml +13 -13
  15. data/app/views/discerner/searches/_summary.html.haml +1 -1
  16. data/app/views/discerner/searches/edit.html.haml +2 -2
  17. data/app/views/discerner/searches/index.html.haml +3 -3
  18. data/app/views/discerner/searches/rename.html.haml +4 -4
  19. data/app/views/discerner/searches/update.js.haml +1 -1
  20. data/app/views/discerner/shared/_categorized_autocompleter_items.html.haml +1 -1
  21. data/app/views/discerner/shared/_error_messages.html.haml +1 -1
  22. data/app/views/layouts/discerner/searches.html.erb +1 -1
  23. data/config/routes.rb +1 -1
  24. data/db/migrate/20140815214547_add_namespace_to_discerner_searches.rb +6 -0
  25. data/db/migrate/20140815214629_add_namespace_to_discerner_dictionaries.rb +6 -0
  26. data/lib/discerner/methods/controllers/export_parameters_controller.rb +2 -2
  27. data/lib/discerner/methods/controllers/parameters_controller.rb +3 -3
  28. data/lib/discerner/methods/controllers/searches_controller.rb +14 -14
  29. data/lib/discerner/methods/helpers/searches_helper.rb +9 -9
  30. data/lib/discerner/methods/models/dictionary.rb +3 -3
  31. data/lib/discerner/methods/models/export_parameter.rb +3 -3
  32. data/lib/discerner/methods/models/operator.rb +5 -5
  33. data/lib/discerner/methods/models/parameter.rb +9 -9
  34. data/lib/discerner/methods/models/parameter_category.rb +5 -5
  35. data/lib/discerner/methods/models/parameter_type.rb +3 -3
  36. data/lib/discerner/methods/models/parameter_value.rb +11 -11
  37. data/lib/discerner/methods/models/parameter_value_categorization.rb +2 -2
  38. data/lib/discerner/methods/models/parameter_value_category.rb +4 -4
  39. data/lib/discerner/methods/models/search.rb +12 -12
  40. data/lib/discerner/methods/models/search_combination.rb +3 -3
  41. data/lib/discerner/methods/models/search_parameter.rb +5 -5
  42. data/lib/discerner/methods/models/search_parameter_value.rb +6 -6
  43. data/lib/discerner/methods/models/soft_delete.rb +1 -1
  44. data/lib/discerner/version.rb +1 -1
  45. data/lib/generators/discerner/dictionary/dictionary_generator.rb +5 -5
  46. data/lib/generators/discerner/install/install_generator.rb +12 -12
  47. data/lib/generators/discerner/install/templates/dictionaries.yml +1 -1
  48. data/lib/generators/discerner/install/templates/models/book.rb +4 -4
  49. data/lib/generators/discerner/install/templates/views/layouts/searches.html.erb +1 -1
  50. data/lib/tasks/cucumber.rake +10 -10
  51. data/lib/tasks/discerner_tasks.rake +5 -5
  52. metadata +8 -6
@@ -1,8 +1,8 @@
1
1
  #discerner_search
2
2
  %br
3
3
  = render 'form'
4
-
4
+
5
5
  - if show_discerner_results?
6
6
  #discerner_results
7
- = render :partial => discerner_results_partial
7
+ = render partial: discerner_results_partial
8
8
  .clear
@@ -3,7 +3,7 @@
3
3
  %h3 Saved searches
4
4
 
5
5
  #filter
6
- = form_tag searches_path, :id => 'discerner_searches_filter', :class => "filter", :method => 'get' do
6
+ = form_tag searches_path, id: 'discerner_searches_filter', class: "filter", method: 'get' do
7
7
  %div.filter
8
8
  = label_tag :query, "Filter by name"
9
9
  = text_field_tag :query, params[:query]
@@ -11,6 +11,6 @@
11
11
  = submit_tag "Search", class: 'button positive'
12
12
  = link_to "Clear search", searches_path
13
13
  #searches-list
14
- = render :partial => "list"
14
+ = render partial: "list"
15
15
  .discerner-buttons
16
- = link_to 'Start a new search', new_search_path, { :class => 'discerner-button discerner-button-positive' }
16
+ = link_to 'Start a new search', new_search_path, { class: 'discerner-button discerner-button-positive' }
@@ -1,6 +1,6 @@
1
- = form_tag search_path(@discerner_search), :method => :put, :remote => :true do
2
- = render 'discerner/shared/error_messages', :object => @discerner_search
1
+ = form_tag search_path(@discerner_search), method: :put, remote: :true do
2
+ = render 'discerner/shared/error_messages', object: @discerner_search
3
3
  = text_field_tag "search[name]", @discerner_search.name.strip
4
4
 
5
- = submit_tag 'Submit', :class => 'discerner-button discerner-button-positive'
6
- = link_to 'Cancel', edit_search_path(@discerner_search), :class => 'discerner-button discerner-button-negative cancel'
5
+ = submit_tag 'Submit', class: 'discerner-button discerner-button-positive'
6
+ = link_to 'Cancel', edit_search_path(@discerner_search), class: 'discerner-button discerner-button-negative cancel'
@@ -1,5 +1,5 @@
1
1
  - if @discerner_search.errors.any?
2
- $("#messages").html("#{escape_javascript(render :partial => 'shared/error_messages', :locals => {:object => @discerner_search})}")
2
+ $("#messages").html("#{escape_javascript(render partial: 'shared/error_messages', locals: {object: @discerner_search})}")
3
3
  - else
4
4
  $("#messages").html('')
5
5
  $('span.discerner_search_name_edit_dialog').siblings('span.discerner_search_name').html("#{@discerner_search.display_name}").show();
@@ -12,4 +12,4 @@
12
12
  - (from...to).each do |j|
13
13
  .criteria
14
14
  %li
15
- = link_to items[j][:name], 'javascript:void(0);', :class => 'categorized_autocompleter_item_link', :rel => "#{items[j][:rel]}"
15
+ = link_to items[j][:name], 'javascript:void(0);', class: 'categorized_autocompleter_item_link', rel: "#{items[j][:rel]}"
@@ -1,5 +1,5 @@
1
1
  - if object.errors.any?
2
- %div{ :id => "error", :class => "message"}
2
+ %div{ id: "error", class: "message"}
3
3
  - object.errors.full_messages.each do |msg|
4
4
  = msg
5
5
  %br
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <%= yield :title %>
5
- <%= stylesheet_link_tag "discerner/application", :media => "all" %>
5
+ <%= stylesheet_link_tag "discerner/application", media: "all" %>
6
6
  <%= javascript_include_tag "discerner/application" %>
7
7
  <%= csrf_meta_tags %>
8
8
  </head>
data/config/routes.rb CHANGED
@@ -2,7 +2,7 @@ Discerner::Engine.routes.draw do
2
2
  resources :searches do
3
3
  member do
4
4
  get :rename
5
- resources :export_parameters, :only => :index do
5
+ resources :export_parameters, only: :index do
6
6
  collection do
7
7
  post :assign
8
8
  end
@@ -0,0 +1,6 @@
1
+ class AddNamespaceToDiscernerSearches < ActiveRecord::Migration
2
+ def change
3
+ add_column :discerner_searches, :namespace_id, :integer
4
+ add_column :discerner_searches, :namespace_type, :string
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddNamespaceToDiscernerDictionaries < ActiveRecord::Migration
2
+ def change
3
+ add_column :discerner_dictionaries, :namespace_id, :integer
4
+ add_column :discerner_dictionaries, :namespace_type, :string
5
+ end
6
+ end
@@ -24,8 +24,8 @@ module Discerner
24
24
  export_parameter_ids = params[:parameter_ids] || []
25
25
 
26
26
  existing_export_parameters.map{ |export_parameter| export_parameter.delete unless export_parameter_ids.include?(export_parameter.parameter_id) }
27
- export_parameter_ids.map{ |parameter_id| @discerner_search.export_parameters.create(:parameter_id => parameter_id) unless existing_export_parameters.where(:parameter_id => parameter_id).any?}
28
- redirect_to search_path(@discerner_search, :format => 'xls')
27
+ export_parameter_ids.map{ |parameter_id| @discerner_search.export_parameters.create(parameter_id: parameter_id) unless existing_export_parameters.where(parameter_id: parameter_id).any?}
28
+ redirect_to search_path(@discerner_search, format: 'xls')
29
29
  end
30
30
 
31
31
  private
@@ -12,9 +12,9 @@ module Discerner
12
12
  @searchable_parameter_values = {}
13
13
  @searchable_parameter_values[@parameter.id] = @parameter_values
14
14
  respond_to do |format|
15
- format.html { render :layout => false }
16
- format.json { render :text => { :type => @parameter.parameter_type.name,
17
- :parameter_values => @parameter_values.map { |v| { :parameter_value_id => v.id, :name => v.name } }}.to_json }
15
+ format.html { render layout: false }
16
+ format.json { render text: { type: @parameter.parameter_type.name,
17
+ parameter_values: @parameter_values.map { |v| { parameter_value_id: v.id, name: v.name } }}.to_json }
18
18
  end
19
19
  end
20
20
 
@@ -3,7 +3,7 @@ module Discerner
3
3
  module Controllers
4
4
  module SearchesController
5
5
  def self.included(base)
6
- base.send :before_filter, :load_search, :only => [:edit, :update, :rename, :destroy, :show]
6
+ base.send :before_filter, :load_search, only: [:edit, :update, :rename, :destroy, :show]
7
7
  end
8
8
 
9
9
  def new
@@ -26,7 +26,7 @@ module Discerner
26
26
  if @discerner_search.save
27
27
  format.html { redirect_to(edit_search_path(@discerner_search)) }
28
28
  else
29
- format.html { render :action => "new" }
29
+ format.html { render action: "new" }
30
30
  end
31
31
  end
32
32
  end
@@ -61,10 +61,10 @@ module Discerner
61
61
  set_searchables
62
62
  respond_to do |format|
63
63
  if @discerner_search.update_attributes(search_params)
64
- format.html { redirect_to(edit_search_path(@discerner_search), :notice => 'Search was successfully updated.') }
64
+ format.html { redirect_to(edit_search_path(@discerner_search), notice: 'Search was successfully updated.') }
65
65
  format.js
66
66
  else
67
- format.html { render :action => "edit" }
67
+ format.html { render action: "edit" }
68
68
  format.js
69
69
  end
70
70
  end
@@ -73,9 +73,9 @@ module Discerner
73
73
  def index
74
74
  searches = Discerner::Search.not_deleted.includes(
75
75
  :dictionary,
76
- :export_parameters => [:parameter => [:parameter_type]],
77
- :search_combinations => [:combined_search => [:search_parameters => [:parameter => [:parameter_type], :search_parameter_values => [:parameter_value]]]],
78
- :search_parameters => [:parameter => [:parameter_type], :search_parameter_values => [:parameter_value]])
76
+ :export_parameters => [parameter: [:parameter_type]],
77
+ search_combinations: [combined_search: [search_parameters: [parameter: [:parameter_type], search_parameter_values: [:parameter_value]]]],
78
+ :search_parameters => [parameter: [:parameter_type], search_parameter_values: [:parameter_value]])
79
79
 
80
80
  username = discerner_user.username unless discerner_user.blank?
81
81
  searches = searches.by_user(username) unless username.blank?
@@ -123,8 +123,8 @@ module Discerner
123
123
  format.csv do
124
124
 
125
125
  send_data @export_data,
126
- :type => 'text/csv; charset=iso-8859-1; header=present',
127
- :disposition => "attachment; filename=#{filename}.csv"
126
+ type: 'text/csv; charset=iso-8859-1; header=present',
127
+ disposition: "attachment; filename=#{filename}.csv"
128
128
  end
129
129
  format.xls do
130
130
  headers["Content-type"] = "application/vnd.ms-excel"
@@ -154,7 +154,7 @@ module Discerner
154
154
  end
155
155
 
156
156
  def dictionary_search_options
157
- options = { :username => nil }
157
+ options = { username: nil }
158
158
  options[:username] = discerner_user.username unless discerner_user.blank?
159
159
  options
160
160
  end
@@ -175,8 +175,8 @@ module Discerner
175
175
  dictionary_ids = @searchable_dictionaries.map(&:id)
176
176
  end
177
177
 
178
- @searchable_parameter_categories = Discerner::ParameterCategory.includes(:dictionary).where(:dictionary_id => dictionary_ids).not_deleted.searchable.ordered_by_name.to_a
179
- parameters_available = Discerner::Parameter.includes(:parameter_type, :parameter_category => [:dictionary]).where(:parameter_category_id => @searchable_parameter_categories.map(&:id)).not_deleted.searchable.to_a
178
+ @searchable_parameter_categories = Discerner::ParameterCategory.includes(:dictionary).where(dictionary_id: dictionary_ids).not_deleted.searchable.ordered_by_name.to_a
179
+ parameters_available = Discerner::Parameter.includes(:parameter_type, parameter_category: [:dictionary]).where(parameter_category_id: @searchable_parameter_categories.map(&:id)).not_deleted.searchable.to_a
180
180
  parameters_used = @discerner_search && @discerner_search.persisted? ? @discerner_search.search_parameters.map{ |sp| sp.parameter } : []
181
181
  @searchable_parameters = parameters_available.flatten | parameters_used.flatten
182
182
  @searchable_parameter_values = map_searchable_values
@@ -186,10 +186,10 @@ module Discerner
186
186
  searchable_values = {}
187
187
 
188
188
  # getting all values at once to save database calls
189
- values_available = Discerner::ParameterValue.includes(:parameter_value_category).not_deleted.where(:parameter_id => @searchable_parameters.map(&:id)).ordered_by_parameter_and_name.to_a
189
+ values_available = Discerner::ParameterValue.includes(:parameter_value_category).not_deleted.where(parameter_id: @searchable_parameters.map(&:id)).ordered_by_parameter_and_name.to_a
190
190
  values_used = []
191
191
  if @discerner_search && @discerner_search.persisted?
192
- values_used = Discerner::ParameterValue.includes(:parameter_value_category).joins(:search_parameter_values => :search_parameter).where(:discerner_search_parameters => {:search_id => @discerner_search.id}).ordered_by_parameter_and_name.to_a
192
+ values_used = Discerner::ParameterValue.includes(:parameter_value_category).joins(search_parameter_values: :search_parameter).where(discerner_search_parameters: {search_id: @discerner_search.id}).ordered_by_parameter_and_name.to_a
193
193
  end
194
194
 
195
195
  @searchable_parameters.each do |sp|
@@ -11,8 +11,8 @@ module Discerner
11
11
  association_prefix = association.to_s.singularize
12
12
  end
13
13
  new_object = f.object.class.reflect_on_association(association).klass.new
14
- fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |form_builder|
15
- render(association_prefix + "_fields", :f => form_builder)
14
+ fields = f.fields_for(association, new_object, child_index: "new_#{association}") do |form_builder|
15
+ render(association_prefix + "_fields", f: form_builder)
16
16
  end
17
17
  escape_javascript(fields)
18
18
  end
@@ -25,11 +25,11 @@ module Discerner
25
25
  end
26
26
 
27
27
  def link_to_remove_fields(name, f, association)
28
- f.hidden_field(:_destroy) + link_to(name, "javascript:void(0);", :class => "delete_#{association.to_s} delete_link icon_link")
28
+ f.hidden_field(:_destroy) + link_to(name, "javascript:void(0);", class: "delete_#{association.to_s} delete_link icon_link")
29
29
  end
30
30
 
31
31
  def link_to_soft_delete_fields(name, f, association)
32
- f.hidden_field(:soft_delete) + link_to(name, "javascript:void(0);", :class => "delete_#{association.to_s} delete_link icon_link")
32
+ f.hidden_field(:soft_delete) + link_to(name, "javascript:void(0);", class: "delete_#{association.to_s} delete_link icon_link")
33
33
  end
34
34
 
35
35
  def nested_record_id(builder, assocation)
@@ -41,11 +41,11 @@ module Discerner
41
41
  unless type.blank?
42
42
  operators = operators.joins(:parameter_types).where("discerner_parameter_types.name in (?)", type)
43
43
  end
44
- operators.includes(:parameter_types).uniq.map {|o| [o.text, o.id, {:class => o.css_class_name}]}
44
+ operators.includes(:parameter_types).uniq.map {|o| [o.text, o.id, {class: o.css_class_name}]}
45
45
  end
46
46
 
47
47
  def dictionary_options(searchable_dictionaries)
48
- searchable_dictionaries.map{|d| [d.name, d.id, {:class => d.css_class_name}]}
48
+ searchable_dictionaries.map{|d| [d.name, d.id, {class: d.css_class_name}]}
49
49
  end
50
50
 
51
51
  def combined_searches_options(search=nil)
@@ -63,14 +63,14 @@ module Discerner
63
63
  searches_used = search.combined_searches
64
64
  searches = searches_available | searches_used
65
65
  end
66
- searches.map {|s| [s.display_name, s.id, {:class => s.dictionary.css_class_name}]}
66
+ searches.map {|s| [s.display_name, s.id, {class: s.dictionary.css_class_name}]}
67
67
  end
68
68
 
69
69
  def parameter_options(searchable_parameters, base_id=nil)
70
70
  options = []
71
71
  searchable_parameters.each do |p|
72
72
  option = [p.display_name, p.id]
73
- html_options = {:class => p.css_class_name}
73
+ html_options = {class: p.css_class_name}
74
74
  html_options[:id] = searchable_object_index(p, base_id) unless base_id.blank?
75
75
  option << html_options
76
76
  options << option
@@ -128,7 +128,7 @@ module Discerner
128
128
  end
129
129
 
130
130
  def discerner_export_link
131
- link_to "Export options", export_parameters_path(@discerner_search), :class => "discerner-button discerner-button-positive"
131
+ link_to "Export options", export_parameters_path(@discerner_search), class: "discerner-button discerner-button-positive"
132
132
  end
133
133
 
134
134
  def format_datetime(datetime)
@@ -6,14 +6,14 @@ module Discerner
6
6
  base.send :include, SoftDelete
7
7
 
8
8
  # Associations
9
- base.send :has_many, :parameter_categories, :dependent => :destroy
9
+ base.send :has_many, :parameter_categories, dependent: :destroy
10
10
  base.send :has_many, :searches
11
11
 
12
12
  #Validations
13
- base.send :validates, :name, :presence => true, :uniqueness => {:message => "for dictionary has already been taken"}
13
+ base.send :validates, :name, presence: true, uniqueness: {message: "for dictionary has already been taken"}
14
14
 
15
15
  # Hooks
16
- base.send :after_commit, :cascade_delete_parameter_categories, :on => :update, :if => Proc.new { |record| record.previous_changes.include?('deleted_at') }
16
+ base.send :after_commit, :cascade_delete_parameter_categories, on: :update, if: Proc.new { |record| record.previous_changes.include?('deleted_at') }
17
17
  end
18
18
 
19
19
  # Instance Methods
@@ -6,15 +6,15 @@ module Discerner
6
6
  base.send :include, SoftDelete
7
7
 
8
8
  # Associations
9
- base.send :belongs_to, :parameter, :inverse_of => :export_parameters
10
- base.send :belongs_to, :search, :inverse_of => :export_parameters
9
+ base.send :belongs_to, :parameter, inverse_of: :export_parameters
10
+ base.send :belongs_to, :search, inverse_of: :export_parameters
11
11
 
12
12
  # Scopes
13
13
  base.send(:scope, :ordered, -> { base.order('discerner_export_parameters.id ASC') })
14
14
  base.send(:scope, :by_parameter_category, ->(parameter_category) { base.includes(:parameter).where('discerner_parameters.parameter_category_id' => parameter_category.id) unless parameter_category.blank?})
15
15
 
16
16
  # Validations
17
- base.send :validates, :parameter, :search, :presence => { :message => "for export parameter can't be blank" }
17
+ base.send :validates, :parameter, :search, presence: { message: "for export parameter can't be blank" }
18
18
  end
19
19
 
20
20
  # Instance Methods
@@ -6,13 +6,13 @@ module Discerner
6
6
  base.send :include, SoftDelete
7
7
 
8
8
  # Associations
9
- base.send :has_many, :search_parameter_values, :inverse_of => :operator
10
- base.send :has_many, :search_combinations, :inverse_of => :operator
11
- base.send :has_and_belongs_to_many, :parameter_types, :join_table => :discerner_operators_parameter_types
9
+ base.send :has_many, :search_parameter_values, inverse_of: :operator
10
+ base.send :has_many, :search_combinations, inverse_of: :operator
11
+ base.send :has_and_belongs_to_many, :parameter_types, join_table: :discerner_operators_parameter_types
12
12
 
13
13
  # Validations
14
- base.send :validates, :symbol, :presence => true, :uniqueness => {:message => "for operator has already been taken"}
15
- base.send :validates, :operator_type, :presence => true
14
+ base.send :validates, :symbol, presence: true, uniqueness: {message: "for operator has already been taken"}
15
+ base.send :validates, :operator_type, presence: true
16
16
  base.send :validate, :type_supported?
17
17
  end
18
18
 
@@ -6,15 +6,15 @@ module Discerner
6
6
  base.send :include, SoftDelete
7
7
 
8
8
  # Associations
9
- base.send :belongs_to, :parameter_category, :inverse_of => :parameters
10
- base.send :belongs_to, :parameter_type, :inverse_of => :parameters
11
- base.send :has_many, :parameter_values, :inverse_of => :parameter, :dependent => :destroy
12
- base.send :has_many, :search_parameters, :inverse_of => :parameter, :dependent => :destroy
13
- base.send :has_many, :export_parameters, :inverse_of => :parameter, :dependent => :destroy
14
- base.send :has_many, :parameter_value_categories, :inverse_of => :parameter, :dependent => :destroy
9
+ base.send :belongs_to, :parameter_category, inverse_of: :parameters
10
+ base.send :belongs_to, :parameter_type, inverse_of: :parameters
11
+ base.send :has_many, :parameter_values, inverse_of: :parameter, dependent: :destroy
12
+ base.send :has_many, :search_parameters, inverse_of: :parameter, dependent: :destroy
13
+ base.send :has_many, :export_parameters, inverse_of: :parameter, dependent: :destroy
14
+ base.send :has_many, :parameter_value_categories, inverse_of: :parameter, dependent: :destroy
15
15
 
16
16
  #Validations
17
- base.send :validates, :name, :unique_identifier, :parameter_category, :presence => { :message => "for parameter can't be blank" }
17
+ base.send :validates, :name, :unique_identifier, :parameter_category, presence: { message: "for parameter can't be blank" }
18
18
  base.send :validate, :validate_unique_identifier
19
19
  base.send :validate, :validate_search_attributes
20
20
  base.send :validate, :validate_export_attributes
@@ -24,7 +24,7 @@ module Discerner
24
24
  base.send(:scope, :exportable, -> {base.not_deleted.where('export_model is not null and export_method is not null')})
25
25
 
26
26
  # Hooks
27
- base.send :after_commit, :cascade_delete_parameter_values, :on => :update, :if => Proc.new { |record| record.previous_changes.include?('deleted_at') }
27
+ base.send :after_commit, :cascade_delete_parameter_values, on: :update, if: Proc.new { |record| record.previous_changes.include?('deleted_at') }
28
28
  end
29
29
 
30
30
  # Instance Methods
@@ -55,7 +55,7 @@ module Discerner
55
55
  def validate_unique_identifier
56
56
  return if self.parameter_category.blank?
57
57
  existing_parameters = Discerner::Parameter.
58
- joins({ :parameter_category => :dictionary }).
58
+ joins({ parameter_category: :dictionary }).
59
59
  where('discerner_dictionaries.id = ? and discerner_parameters.unique_identifier = ?', self.parameter_category.dictionary.id, self.unique_identifier)
60
60
  existing_parameters = existing_parameters.where('discerner_parameters.id != ?', self.id) unless self.id.blank?
61
61
  errors.add(:base,"Unique identifier has to be unique within dictionary.") if existing_parameters.any?
@@ -6,12 +6,12 @@ module Discerner
6
6
  base.send :include, SoftDelete
7
7
 
8
8
  # Associations
9
- base.send :belongs_to, :dictionary, :inverse_of => :parameter_categories
10
- base.send :has_many, :parameters, :inverse_of => :parameter_category, :dependent => :destroy
9
+ base.send :belongs_to, :dictionary, inverse_of: :parameter_categories
10
+ base.send :has_many, :parameters, inverse_of: :parameter_category, dependent: :destroy
11
11
 
12
12
  # Validations
13
- base.send :validates, :name, :presence => true, :uniqueness => { :scope => :dictionary_id, :message => "for parameter category has already been taken"}
14
- base.send :validates, :dictionary, :presence => { :message => "for parameter category can't be blank" }
13
+ base.send :validates, :name, presence: true, uniqueness: { scope: :dictionary_id, message: "for parameter category has already been taken"}
14
+ base.send :validates, :dictionary, presence: { message: "for parameter category can't be blank" }
15
15
 
16
16
  # Scopes
17
17
  base.send(:scope, :searchable, -> {base.includes(:parameters).where('discerner_parameters.search_model is not null and discerner_parameters.search_method is not null and discerner_parameters.deleted_at is null').references(:discerner_parameters)})
@@ -19,7 +19,7 @@ module Discerner
19
19
  base.send(:scope, :ordered_by_name, -> {base.order('discerner_parameter_categories.name ASC')})
20
20
 
21
21
  # Hooks
22
- base.send :after_commit, :cascade_delete_parameters, :on => :update, :if => Proc.new { |record| record.previous_changes.include?('deleted_at') }
22
+ base.send :after_commit, :cascade_delete_parameters, on: :update, if: Proc.new { |record| record.previous_changes.include?('deleted_at') }
23
23
  end
24
24
 
25
25
  # Instance Methods
@@ -6,11 +6,11 @@ module Discerner
6
6
  base.send :include, SoftDelete
7
7
 
8
8
  # Associations
9
- base.send :has_many, :parameters, :inverse_of => :parameter_type
10
- base.send :has_and_belongs_to_many, :operators, :join_table => :discerner_operators_parameter_types
9
+ base.send :has_many, :parameters, inverse_of: :parameter_type
10
+ base.send :has_and_belongs_to_many, :operators, join_table: :discerner_operators_parameter_types
11
11
 
12
12
  # Validations
13
- base.send :validates, :name, :presence => true, :uniqueness => {:message => "for parameter type has already been taken"}
13
+ base.send :validates, :name, presence: true, uniqueness: {message: "for parameter type has already been taken"}
14
14
  base.send :validate, :name_supported?
15
15
  end
16
16
 
@@ -6,9 +6,9 @@ module Discerner
6
6
  base.send :include, SoftDelete
7
7
 
8
8
  # Associations
9
- base.send :belongs_to, :parameter, :inverse_of => :parameter_values
10
- base.send :has_many, :search_parameter_values, :inverse_of => :parameter_value, :dependent => :destroy
11
- base.send :has_one, :parameter_value_categorization, :inverse_of => :parameter_value, :dependent => :destroy
9
+ base.send :belongs_to, :parameter, inverse_of: :parameter_values
10
+ base.send :has_many, :search_parameter_values, inverse_of: :parameter_value, dependent: :destroy
11
+ base.send :has_one, :parameter_value_categorization, inverse_of: :parameter_value, dependent: :destroy
12
12
  base.send :has_one, :parameter_value_category, :through=> :parameter_value_categorization
13
13
 
14
14
  # Scopes
@@ -16,16 +16,16 @@ module Discerner
16
16
  base.send(:scope, :ordered_by_parameter_and_name, -> { base.order('discerner_parameter_values.parameter_id ASC, discerner_parameter_values.name ASC') })
17
17
 
18
18
  #Validations
19
- base.send :validates, :parameter, :presence => true
20
- base.send :validates, :search_value, :length => { :maximum => 1000 }, :uniqueness => {:scope => :parameter_id, :message => "for parameter value has already been taken"}
21
- base.send :validates, :name, :presence => true, :length => { :maximum => 1000 }
19
+ base.send :validates, :parameter, presence: true
20
+ base.send :validates, :search_value, length: { maximum: 1000 }, uniqueness: {scope: :parameter_id, message: "for parameter value has already been taken"}
21
+ base.send :validates, :name, presence: true, length: { maximum: 1000 }
22
22
  base.send :validate, :parameter_category_belongs_to_parameter
23
23
 
24
24
  # Hooks
25
- base.send :after_commit, :create_search_parameter_values, :on => :create
26
- base.send :after_commit, :update_search_parameter_values, :on => :update, :if => Proc.new { |record| record.previous_changes.include?('deleted_at') }
25
+ base.send :after_commit, :create_search_parameter_values, on: :create
26
+ base.send :after_commit, :update_search_parameter_values, on: :update, if: Proc.new { |record| record.previous_changes.include?('deleted_at') }
27
27
  base.send :scope, :categorized, -> {base.joins(:parameter_value_category)}
28
- base.send :scope, :uncategorized, -> {base.includes(:parameter_value_category).where(:discerner_parameter_value_categories => {:name => nil})}
28
+ base.send :scope, :uncategorized, -> {base.includes(:parameter_value_category).where(discerner_parameter_value_categories: {name: nil})}
29
29
  end
30
30
 
31
31
  # Instance Methods
@@ -61,9 +61,9 @@ module Discerner
61
61
  return if parameter.blank? || parameter.parameter_type.blank?
62
62
  if parameter.parameter_type.name == 'list'
63
63
  parameter.search_parameters.each do |sp|
64
- if sp.search_parameter_values.where(:parameter_value_id => id).blank?
64
+ if sp.search_parameter_values.where(parameter_value_id: id).blank?
65
65
  max_display_order = sp.search_parameter_values.ordered_by_display_order.last.display_order || -1
66
- sp.search_parameter_values.build(:parameter_value_id => id, :display_order => max_display_order + 1)
66
+ sp.search_parameter_values.build(parameter_value_id: id, display_order: max_display_order + 1)
67
67
  sp.save
68
68
  end
69
69
  end