lib/trust/inheritable_attribute.rb in trust-0.6.3 vs lib/trust/inheritable_attribute.rb in trust-0.7.0
- old
+ new
@@ -21,13 +21,14 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module Trust
+ # = Trust InheritableAttribute
module InheritableAttribute
- def self.deep_copy value
+ def self.deep_copy( value) #:nodoc:
if value.is_a? Hash
Hash[*value.map{ |k,v| [self.deep_copy(k),self.deep_copy(v)] }.flatten(1)]
elsif value.is_a? Array
value.map{ |v| self.deep_copy(v) }
elsif value.is_a? Symbol
@@ -38,14 +39,15 @@
end
extend ActiveSupport::Concern
module ClassMethods
- # Creates an inheritable attribute with accessors in the singleton class. Derived classes inherit the
- # attributes. This is especially helpful with arrays or hashes that are extended in the inheritance
- # chain. Note that you have to initialize the inheritable attribute.
+ # Creates an inheritable attribute with accessors in the singleton class.
+ #
+ # Derived classes inherit the attributes. This is especially helpful with arrays or hashes that
+ # are extended in the inheritance chain. Note that you have to initialize the inheritable attribute.
#
- # Example:
+ # === Example
#
# class Cat
# inheritable_attr :drinks
# self.drinks = ["Becks"]
#