Class: Aspera::Cli::AttrAccessor
- Inherits:
-
Object
- Object
- Aspera::Cli::AttrAccessor
- Defined in:
- lib/aspera/cli/manager.rb
Overview
option is retrieved from another object using accessor
Instance Method Summary collapse
-
#initialize(object, method_name, option_name) ⇒ AttrAccessor
constructor
attr_accessor :object attr_accessor :method_name.
- #value ⇒ Object
- #value=(val) ⇒ Object
- #writer_method ⇒ Object
Constructor Details
#initialize(object, method_name, option_name) ⇒ AttrAccessor
attr_accessor :object attr_accessor :method_name
18 19 20 21 22 23 24 25 |
# File 'lib/aspera/cli/manager.rb', line 18 def initialize(object, method_name, option_name) @object = object @method = method_name @option_name = option_name @has_writer = @object.respond_to?(writer_method) Log.log.trace1{"AttrAccessor: #{@option_name}: #{@object.class}.#{@method}: writer=#{@has_writer}"} Aspera.assert(@object.respond_to?(@method)) {"#{object} does not respond to #{method_name}"} end |
Instance Method Details
#value ⇒ Object
27 28 29 30 |
# File 'lib/aspera/cli/manager.rb', line 27 def value return @object.send(@method) if @has_writer return @object.send(@method, @option_name, :get) end |
#value=(val) ⇒ Object
32 33 34 35 36 |
# File 'lib/aspera/cli/manager.rb', line 32 def value=(val) Log.log.trace1{"AttrAccessor: = #{@method} #{@option_name} :set #{val}, writer=#{@has_writer}"} return @object.send(writer_method, val) if @has_writer return @object.send(@method, @option_name, :set, val) end |
#writer_method ⇒ Object
38 39 40 |
# File 'lib/aspera/cli/manager.rb', line 38 def writer_method return "#{@method}=" end |