Class: ThingTank

Inherits:
CouchRest::Model::Base
  • Object
show all
Includes:
Callbacks, CharacterHandling, ForceUpdate, InstanceMethods, SharedMethods, Shortcuts
Defined in:
lib/thingtank.rb,
lib/thingtank/callbacks.rb,
lib/thingtank/character.rb,
lib/thingtank/shortcuts.rb,
lib/thingtank/thingtank.rb,
lib/thingtank/dependencies.rb,
lib/thingtank/force_update.rb,
lib/thingtank/shared_methods.rb,
lib/thingtank/instance_methods.rb,
lib/thingtank/character_handling.rb

Overview

TODO: character validator

Defined Under Namespace

Modules: Callbacks, CharacterHandling, ForceUpdate, InstanceMethods, SharedMethods, Shortcuts Classes: Character, Dependencies, FakeBase

Instance Method Summary collapse

Methods included from Callbacks

included

Methods included from Shortcuts

included

Methods included from CharacterHandling

included

Methods included from InstanceMethods

included

Methods included from SharedMethods

included

Methods included from ForceUpdate

included

Instance Method Details

#character_view_by(klass, *keys) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/thingtank/thingtank.rb', line 10

def character_view_by(klass, *keys)
  opts = keys.pop if keys.last.is_a?(Hash)
  opts ||= {}
  opts[:guards] ||= []
  # there is no "inArray" like function in couchdb, see http://stackoverflow.com/questions/3740464/i-have-to-write-every-function-i-need-for-couchdb
  opts[:guards] << "((doc['characters'] !== undefined) && (function (item,arr) { for(p=0;p<arr.length;p++) if (item == arr[p]) return true; return false;})('#{klass.to_s}',doc['characters']))"
  keys << opts
  view_by(*keys)
end