Module: Shared::IsData::ClassMethods

Defined in:
app/models/concerns/shared/is_data.rb

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) batch_update_attribute(ids: [], attribute: nil, value: nil)

Returns use update vs. a set of ids, but require the update to pass for all or none

Returns:

  • (Boolean)

    use update vs. a set of ids, but require the update to pass for all or none



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/models/concerns/shared/is_data.rb', line 57

def batch_update_attribute(ids: [], attribute: nil, value: nil)
  return false if ids.empty? || attribute.nil? || value.nil? 
  begin
    self.transaction do 
      self.where(id: ids).find_each do |li|
        li.update(attribute => value)
      end
    end
  rescue
    return false
  end
  true
end

- (Boolean) is_community?

Returns:

  • (Boolean)


51
52
53
# File 'app/models/concerns/shared/is_data.rb', line 51

def is_community?
  self < Shared::SharedAcrossProjects ? true : false
end