/alt_accessor

Makers Academy | Week 5 | Challenge | Part III (bonus)

Primary LanguageRuby

#Alt_Accessor

##Makers Academy | Week 5 | Challenge | Part III (Bonus)

##Table of Contents

##General Description

This repo contians my answer to Week 5 Friday Challange (Part III (Bonus) of the course at Makers Academy.

This challange was to write an effective Ruby-based equivallent to the attr_accessor() method. This method utilizes metaprogramming techniques to dynamically create other methods which can access and set instance variables.

The equivallent method offered here, alt_accessor(), was created according to TDD methodology (tests written with Rspec).

##Guidelines

  • Re-implement the attr_accessor method

  • The idea is that this method will create methods dynamically to access and to set instance variables

    For example, if we implement:

alt_accessor :name

The alternative method will create the following methods:

def name
	@name
end

def name=(name)
	@name = name
end

##How to Install

To install and run locally, clone the repo and run:

$> cd alt_accessor
$> irb
>> require './lib/alt_accessor.rb'

##Testing

Tests were written with Rspec (3.1.0).

To run the test in terminal, clone the repo to a local folder and run:

$> cd alt_accessor
$> rspec

##License

Released under the MIT license.