Module: Hashstructor
- Defined in:
- lib/hashstructor.rb,
lib/hashstructor.rb,
lib/hashstructor/member.rb,
lib/hashstructor/version.rb,
lib/hashstructor/class_methods.rb,
lib/hashstructor/instance_methods.rb
Overview
Allows the “hashstruction” of objects by predefining an #initialize method off of the InstanceMethods#member declarations within the class spec.
The secret sauce for this module is in InstanceMethods and ClassMethods, respectively.
Defined Under Namespace
Modules: ClassMethods, InstanceMethods Classes: HashstructorError, Member
Constant Summary
- VERSION =
The gem version. As one does.
"1.0.0"
Class Method Summary (collapse)
-
+ (Object) decorate(mod)
The actual magic of both #prepended and #included; bolts the class methods onto the prepending/including module.
-
+ (Object) included(mod)
Fires when this module is
include
d. -
+ (Object) prepended(mod)
Fires when this module is
prepend
ed.
Class Method Details
+ (Object) decorate(mod)
The actual magic of both #prepended and #included; bolts the class methods onto the prepending/including module.
36 37 38 39 |
# File 'lib/hashstructor.rb', line 36 def self.decorate(mod) mod.instance_variable_set("@hashstructor_members", []) mod.extend(Hashstructor::ClassMethods) end |
+ (Object) included(mod)
Fires when this module is include
d. This is provided for Ruby
1.9.x, but classes that include
this have to explicitly invoke
Hashstructor::InstanceMethods#hashstruct.
30 31 32 |
# File 'lib/hashstructor.rb', line 30 def self.included(mod) Hashstructor.decorate(mod) end |
+ (Object) prepended(mod)
Fires when this module is prepend
ed. This is the most
cromulent way to use Hashstructor in Ruby 2.x.
23 24 25 |
# File 'lib/hashstructor.rb', line 23 def self.prepended(mod) Hashstructor.decorate(mod) end |