Class: Role
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Role
- Defined in:
- app/models/role.rb
Class Method Summary collapse
Class Method Details
.find_or_create_named(*names) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/models/role.rb', line 22 def self.find_or_create_named *names names.flatten! names.compact! (existing = named(names)).to_a + (names - existing.map(&:name)).map { |name| create name: name } end |
.with_relations(&block) ⇒ Object
32 33 34 35 36 |
# File 'app/models/role.rb', line 32 def self.with_relations &block joins(:relations).merge( Relation.instance_eval &block ).uniq end |