Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Find schema by the field name (with some refractor)

  • Loading branch information...
commit 0bc27fa1634541c41074d94d39d9e5db354b5b8a 1 parent 911eb2f
@pol pol authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/yogo/collection/property.rb
View
13 lib/yogo/collection/property.rb
@@ -39,13 +39,24 @@ def versions
Yogo::Collection::Property.with_deleted.all(:original_uid=>self.id.to_s, :order=>[:deleted_at])
end
+ def self.by_field_name(fname)
+ get(self.field_name_to_uid(fname))
+ end
+
+ def self.field_name_to_uid(fname)
+ fname[6..-1].gsub('_','-')
+ end
+
+ def self.uid_to_field_name(uid)
+ 'field_' + uid.to_s.gsub('-','_')
+ end
def field_name
self.to_s
end
def to_s
- 'field_' + self.id.to_s.gsub('-','_')
+ self.class.uid_to_field_name(self.id)
end
def as_json(opts=nil)
Please sign in to comment.
Something went wrong with that request. Please try again.