Class: Ooz::Model::Ooze

Inherits:
Base::Ooze show all
Defined in:
lib/ooz/model/ooze.rb

Instance Attribute Summary

Attributes inherited from Base::Model

#root

Attributes inherited from Common::BaseModel

#doc

Instance Method Summary collapse

Methods inherited from Base::Ooze

#initialize

Methods inherited from Base::Model

#initialize, #ooze

Methods inherited from Common::BaseModel

#as_json, #as_update, build, #changed?, #consolidate!, #initialize, #new_change?, #print, #to_json, #undo!, #update_last_change!

Methods inherited from Common::BaseClass

overridable_const, passthrough, passthrough_arr, passthrough_cls

Constructor Details

This class inherits a constructor from Ooz::Base::Ooze

Instance Method Details

#bindingsObject



81
82
83
84
85
# File 'lib/ooz/model/ooze.rb', line 81

def bindings
  forces.reduce([]) do |binds, f|
    binds + f.bindings
  end
end

#bindings_by_fieldObject



87
88
89
90
91
# File 'lib/ooz/model/ooze.rb', line 87

def bindings_by_field
  bindings.group_by do |b|
    b.reference_id
  end
end

#fieldsObject



39
40
41
# File 'lib/ooz/model/ooze.rb', line 39

def fields
  membranes
end

#fields_hash(key: "_id", silent: true) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ooz/model/ooze.rb', line 43

def fields_hash(key: "_id", silent: true)
  fields.group_by do |fld|
    fld.send(key)
  end.transform_values do |flds|
    if flds.length == 1
      flds.first
    else
      master = flds.first
      next master unless master.is_a?(Ooz::Model::Field::Select)
      rest   = flds[1..-1]
      rest.each do |fld|
        if fld.is_a?(Ooz::Model::Field::Select)
          master.other    ||= fld.other
          master.multiple ||= fld.multiple
          Ooz::Base::Field::Select.merge_options(master, fld, silent: silent)
        end
      end
      master
    end
  end
end

#sectionsObject



65
66
67
# File 'lib/ooz/model/ooze.rb', line 65

def sections
  flow_nodes
end

#sections_by_fieldObject



73
74
75
76
77
78
79
# File 'lib/ooz/model/ooze.rb', line 73

def sections_by_field
  sections.map do |sec|
    sec.field_ids.map do |id|
      [id, sec]
    end
  end.flatten(1).to_h
end

#sections_hashObject



69
70
71
# File 'lib/ooz/model/ooze.rb', line 69

def sections_hash
  to_hash(sections)
end

#stagesObject



18
19
20
21
# File 'lib/ooz/model/ooze.rb', line 18

def stages
  return [] if !stages?
  evolution.stages
end

#stages?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/ooz/model/ooze.rb', line 14

def stages?
  evolution && evolution.stages&.length > 0
end

#stages_by_sectionObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ooz/model/ooze.rb', line 27

def stages_by_section
  stages.map do |stg|
    stg.flow_node_ids.map do |id|
      [id, stg]
    end
  end.flatten(1).group_by do |pair|
    pair.first
  end.transform_values do |arr_pairs|
    arr_pairs.map {|pair| pair.last}
  end
end

#stages_hashObject



23
24
25
# File 'lib/ooz/model/ooze.rb', line 23

def stages_hash
  to_hash(stages)
end

#tagged?(tag, search_on: :tags) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/ooz/model/ooze.rb', line 9

def tagged?(tag, search_on: :tags)
  haystack = self.send(search_on)
  haystack.include?(tag)
end