Class: GreenPepper::InstanceFieldAccessor

Inherits:
Object
  • Object
show all
Defined in:
lib/greenpepper/example/fieldaccessor.rb

Direct Known Subclasses

ReaderFieldAccessor, WriterFieldAccessor

Instance Method Summary collapse

Instance Method Details

#access_instance_field(fixture, field_name, value = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/greenpepper/example/fieldaccessor.rb', line 11

def access_instance_field(fixture, field_name, value=nil)
  method = fixture.public_methods.find{
    |method| method.to_s == field_name
  }
  if method.nil?
    raise ErrorHelper.raise_greenpepper_missing_method(
      field_name, fixture)
  else
    call_accessor fixture.method(field_name), value
  end
end