Module: StrokeDB::Meta::Util

Defined in:
lib/strokedb/document/util.rb

Instance Method Summary collapse

Instance Method Details

#check_condition(condition) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/strokedb/document/util.rb', line 12

def check_condition(condition)
  case condition
  when Symbol, String then return
  else
    raise ArgumentError, ":if/:unless clauses need to be either a symbol or string (slotname or method name)"
  end
end

#evaluate_condition(condition, doc) ⇒ Object



20
21
22
23
24
# File 'lib/strokedb/document/util.rb', line 20

def evaluate_condition(condition, doc)
  case condition
  when String then doc.send(condition)
  end
end

#grep_slots(doc, prefix) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/strokedb/document/util.rb', line 4

def grep_slots(doc, prefix)
  doc.meta.slotnames.each do |slotname|
    if slotname[0..(prefix.length - 1)] == prefix
      yield slotname[prefix.length..-1], slotname
    end
  end
end