Class: Command::OgCommands::HasOneCommand
- Inherits:
-
Command
- Object
- Command
- Command::OgCommands::HasOneCommand
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_one(field) ⇒ Object
104
105
106
107
108
109
110
111
112
|
# File 'lib/command-set/og.rb', line 104
def has_one(field)
define_method(:get_value) do
entity.__send__(field)
end
define_method(:set_value) do |value|
entity.__send__("#{field}=", value)
end
end
|
.identified_by(name, &block) ⇒ Object
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/command-set/og.rb', line 114
def identified_by(name, &block)
if block.nil?
define_method(:get_label) do |value|
return "" unless value.respond_to?(name.intern)
value.__send__(name.intern).to_s
end
else
define_method(:get_label) do |value|
return "" unless value.respond_to?(name.intern)
block[value.__send__(name.intern)]
end
end
end
|
.optional_value(target_class, select_by) ⇒ Object
100
101
102
|
# File 'lib/command-set/og.rb', line 100
def optional_value(target_class, select_by)
optional_argument OgArgument.new(:value, target_class, select_by)
end
|
Instance Method Details
#entity ⇒ Object
95
96
97
|
# File 'lib/command-set/og.rb', line 95
def entity
subject.current_state.last
end
|