Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

dominictarr/quick_attr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

	basic usage: 
		require 'quick_attr'; 
		class C
			extend QuickAttr
			quick_attr :name, :smell
		end

		#set attr by passing value
		c = C.new.name("bobaloba ding-dong").smell("fishy")

		#get attr by calling without args...
		puts c.name	# bobaloba ding-dong
		puts c.smell	# fishy
		
		
	also, if you want an attribute that defaults to a certain class, for example an array:
	
		class C
		  quick_array :monkey_poems
		end		

		c=  C.new
		c.monkey_poems << "asdas sdfjg dfg alsdasdlfj sdlfkj sd"
		puts c.monkey_poems.inspect
		-> ["asdas sdfjg dfg alsdasdlfj sdlfkj sd"]
		you can also set it like before.
		
		c.monkey_poems(:a,:s,:d:,:f)
		puts c.monkey_poems.inspect
		-> [:a,:s,:d,:f]
		
	quick_hash is also like quick_array.
	
	quick_klass expects the first argument to be a class a creates attr which behaves like attr but defaults to klass
	i.e.
	class NewArray < Array; end
	quick_klass NewArray, :new_array
	
	
	
	code is at: http://github.com/dominictarr/quick_attr
		

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages