Class: Tag::Runner

Inherits:
Boson::Runner
  • Object
show all
Defined in:
lib/tag/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.model_optionObject



5
6
7
# File 'lib/tag/runner.rb', line 5

def self.model_option
  option :model, :type => :string
end

Instance Method Details

#add(*items) ⇒ Object



12
13
14
15
# File 'lib/tag/runner.rb', line 12

def add(*items)
  options = items[-1].is_a?(Hash) ? items.pop : {}
  Tag.store(options[:model]).multi_tag(items, options[:tags])
end

#itemsObject



55
56
57
# File 'lib/tag/runner.rb', line 55

def items
  puts Tag.store.items
end

#list(tag, options = {}) ⇒ Object



27
28
29
# File 'lib/tag/runner.rb', line 27

def list(tag, options={})
  puts Tag.store(options[:model]).list(tag)
end

#modelsObject



50
51
52
# File 'lib/tag/runner.rb', line 50

def models
  puts Tag::Store.models
end

#rm(*items) ⇒ Object



20
21
22
23
# File 'lib/tag/runner.rb', line 20

def rm(*items)
  options = items[-1].is_a?(Hash) ? items.pop : {}
  Tag.store(options[:model]).multi_remove_tag(items, options[:tags])
end

#tags(*args) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/tag/runner.rb', line 34

def tags(*args)
  options = args[-1].is_a?(Hash) ? args.pop : {}
  if options[:rm]
    Tag.store(options[:model]).delete_tags(*args)
  else
    puts Tag.store(options[:model]).list_tags
  end
end

#tree(options = {}) ⇒ Object



45
46
47
# File 'lib/tag/runner.rb', line 45

def tree(options={})
  puts Tag.store(options[:model]).tree
end