Module: LiveRecord::BaseChannel::Helpers
- Defined in:
- app/channels/live_record/base_channel/helpers.rb
Class Method Summary collapse
- .queryable_attributes(model_class, current_user) ⇒ Object
- .whitelisted_attributes(record, current_user) ⇒ Object
Class Method Details
.queryable_attributes(model_class, current_user) ⇒ Object
20 21 22 23 24 25 |
# File 'app/channels/live_record/base_channel/helpers.rb', line 20 def self.queryable_attributes(model_class, current_user) queryable_attributes = model_class.live_record_queryable_attributes(current_user) raise "#{model_class}.live_record_queryable_attributes should return an array" unless queryable_attributes.is_a? Array queryable_attributes = queryable_attributes.map(&:to_s) queryable_attributes.to_set end |
.whitelisted_attributes(record, current_user) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/channels/live_record/base_channel/helpers.rb', line 4 def self.whitelisted_attributes(record, current_user) whitelisted_attributes = record.class.live_record_whitelisted_attributes(record, current_user) unless whitelisted_attributes.is_a? Array raise "#{record.class}.live_record_whitelisted_attributes should return an array" end whitelisted_attributes = whitelisted_attributes.map(&:to_s) if !whitelisted_attributes.empty? && !whitelisted_attributes.include?('id') raise "#{record.class}.live_record_whitelisted_attributes should return an array that also includes the :id attribute, as you are authorizing at least one other attribute along with it." end whitelisted_attributes.to_set end |