Class: Command::OgCommands::HasManyListCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/command-set/og.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Command

raw_stderr, raw_stdout, wrap_stderr, wrap_stdout

Class Method Details

.has_many(target_name) ⇒ Object



161
162
163
164
165
# File 'lib/command-set/og.rb', line 161

def has_many(target_name) 
  define_method(:target_name) do
    target_name
  end
end

.listed_as(list_as) ⇒ Object



167
168
169
170
171
# File 'lib/command-set/og.rb', line 167

def listed_as(list_as)
  define_method(:list_as) do
    list_as
  end
end

Instance Method Details

#entityObject



149
150
151
# File 'lib/command-set/og.rb', line 149

def entity
  subject.current_state.last
end

#object_list(options = {}) ⇒ Object



153
154
155
156
157
158
# File 'lib/command-set/og.rb', line 153

def object_list(options={})
  objects=entity.__send__("find_#{target_name}", options)
  return objects.map do |object|
    object.__send__(list_as)
  end
end