How to use elements method of ClassMethods Package

Best Site_prism code snippet using ClassMethods.elements

configurable.rb

Source:configurable.rb Github

copy

Full Screen

...83 # Fields that are suppressed in the default inspection of a configuration.84 NO_INSPECT =85 %i(facet_fields index_fields show_fields search_fields sort_fields)86 # Generate an easier-to-read inspection of a configuration by coverting87 # Hash-like elements to Hash.88 #89 # @param [ActiveSupport::OrderedOptions] config90 # @param [TrueClass, FalseClass, nil] all91 #92 # @return [String]93 #94 def config_inspect(config, all = false)95 h = config.to_h96 h = h.except(*NO_INSPECT) unless all97 hashify(h).pretty_inspect.gsub(/:([^=\n]+)(=>)/, '\1 \2 ')98 end99 # =========================================================================100 # :section:101 # =========================================================================102 private103 # Covert Hash-like elements to Hash.104 #105 # @param [Object] value106 #107 # @return [Object]108 #109 def hashify(value)110 case value111 when Hash, OpenStruct112 value.to_h.map { |k, v| [hashify(k), hashify(v)] }.to_h113 when Array114 value.map { |v| hashify(v) }115 else116 value117 end...

Full Screen

Full Screen

active_record.rb

Source:active_record.rb Github

copy

Full Screen

...22 end23 end24 def find_by_sorted_ids(new_sorted_element_ids)25 # find records in unorder list26 elements = self.where(:id => new_sorted_element_ids).all27 # sort it using ruby method28 sorted_elements = []29 new_sorted_element_ids.each do |id|30 id = id.to_i31 sorted_elements << elements.find{ |x| x.id == id }32 end33 sorted_elements.blank? ? sorted_elements : sorted_elements.uniq34 end35 end #module ClassMethods36 module ModelHelpersClassMethods37 extend ActiveSupport::Concern38 included do39 cattr_accessor :is_flat_drag_tree, :drag_tree_scope_column40 before_validation :set_position41 end42 module ClassMethods43 def behaves_as_a_drag_tree44 true45 end46 def make_flat_drag_tree47 self.is_flat_drag_tree = true...

Full Screen

Full Screen

action_controller.rb

Source:action_controller.rb Github

copy

Full Screen

...36 render :json => {:success => false}37 return38 end39 if params[:element_ids]40 save_data_for_elements(params)41 else42 nestable_serialized_data = JSON.parse(params[:nestable_serialized_data])43 _update_position_for_pages(self.class.drag_class, nestable_serialized_data, nil)44 end45 render :json => {:success => true}46 end47 def save_data_for_elements(params)48 ids = params[:element_ids].split(",")49 elements = self.class.drag_class.find_by_sorted_ids(ids)50 elements.each_with_index do |element , index|51 element.update_attributes!({:position => index})52 end53 end54 def _update_position_for_pages(klass, pages, parent_id=nil)55 pages.each_with_index do |row, index|56 klass.update(row["id"], :position => index, :parent_id => parent_id)57 unless row["children"].blank?58 _update_position_for_pages(klass, row["children"], row["id"])59 end60 end61 end62 end #ControllerHelperClassMethods63 end64 end #DragTree...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful