Sha256: 07d1d223e6b8eb40f6a452c9ea3ad13baed4f15caea0d14159bc0366977f1abc
Contents?: true
Size: 721 Bytes
Versions: 4
Compression:
Stored size: 721 Bytes
Contents
module PushType class NodeField < SelectField include PushType::Fields::Relations options template: 'relation', field_options: {}, root: '/' def relation_class super rescue NameError PushType::Node end def relation_root root = relation_class.not_trash root = root.find_by_path(@opts[:root].split('/')) unless @opts[:root] == '/' root or raise "Cannot find root node at path '#{ @opts[:root] }'" end initialized_on_node do |object, field| object.class_eval do define_method field.name.to_sym do field.relation_class.not_trash.find send(field.json_key) if send(field.json_key).present? end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems