aboutsummaryrefslogtreecommitdiffstats
path: root/lib/model_attribute.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/model_attribute.rb')
-rw-r--r--lib/model_attribute.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/model_attribute.rb b/lib/model_attribute.rb
index 78c9168eb..60580e306 100644
--- a/lib/model_attribute.rb
+++ b/lib/model_attribute.rb
@@ -21,6 +21,14 @@ class ModelAttribute
all.group_by(&:klass)
end
+ def self.from_code(code)
+ klass, name = code.split('#').map(&:to_sym)
+
+ methods_by_class(klass).select do |model_attr|
+ model_attr.name == name
+ end.first
+ end
+
def self.methods_by_class(klass)
all.select do |model_attr|
model_attr.klass == klass