diff options
| author | Teddy Wing | 2017-09-22 12:42:41 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-09-22 12:42:41 +0200 | 
| commit | 9086e4c7d253927e7fad07bcd4eb194eeff393ca (patch) | |
| tree | 102d744113f1a605ac0a5ea0eb3323ca779f9c5d /lib | |
| parent | 404b143af9ed49912e1e0065c832639188aa87de (diff) | |
| download | chouette-core-9086e4c7d253927e7fad07bcd4eb194eeff393ca.tar.bz2 | |
ModelAttribute: Add `.group_by_class` method
This returns all defined `ModelAttribute`s as a hash of class keys
containing lists of the attributes they contain.
Refs #4401
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/model_attribute.rb | 4 | 
1 files changed, 4 insertions, 0 deletions
| diff --git a/lib/model_attribute.rb b/lib/model_attribute.rb index 53c0b7a46..78c9168eb 100644 --- a/lib/model_attribute.rb +++ b/lib/model_attribute.rb @@ -17,6 +17,10 @@ class ModelAttribute        .uniq    end +  def self.group_by_class +    all.group_by(&:klass) +  end +    def self.methods_by_class(klass)      all.select do |model_attr|        model_attr.klass == klass | 
