Module: Dataflow::PropertiesMixin::ClassMethods

Defined in:
lib/dataflow/properties_mixin.rb

Instance Method Summary collapse

Instance Method Details

#add_property(name, opts) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/dataflow/properties_mixin.rb', line 18

def add_property(name, opts)
  # skip properties that start by underscore
  return if name =~ /^_/
  @properties ||= {}
  @properties[name] ||= {}
  @properties[name].merge!(opts)
end

#field(name, opts = {}) ⇒ Object

Override the mongoid ‘field` method to produce a list of properties for each node.



9
10
11
12
13
14
15
16
# File 'lib/dataflow/properties_mixin.rb', line 9

def field(name, opts = {})
  add_property(name, opts)
  # make sure we pass mongoid-only keys to the superclass
  opts.delete(:editable)
  opts.delete(:required_for_computing)
  opts.delete(:values)
  super
end

#propertiesObject



26
27
28
29
30
31
32
# File 'lib/dataflow/properties_mixin.rb', line 26

def properties
  @properties ||= {}
  @properties.merge(superclass.properties)
rescue NoMethodError => e
  # handle cases where we're already on top of the hierarchy.
  @properties
end