aetherical_utils 0.0.2 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data.tar.gz.sig CHANGED
Binary file
@@ -8,40 +8,47 @@
8
8
 
9
9
  module AethericalUtils
10
10
  module Attribute
11
- # Attribute is a method of declaring default values for a property.
12
- # These default values may be either an explicit value, such as 1,
13
- # or "dog", or they may be a block _which is evaluated at runtime_.
14
- # As such, the block could return different values each time it is
15
- # invoked.
16
- #
17
- # If the attribute is a boolean, denoted by '?', such as
18
- # 'billable?', then the library will correctly create 'billable?'
19
- # and 'billable=' methods.
20
- #
21
- # *Important*: Since the instance variable ('@billable') may not be
22
- # defined or the attribute may represent the value returned by a
23
- # block, it is important to access the attribute via the method
24
- # ('billable?') as opposed to the instance variable name
25
- # ('@billable').
26
11
 
27
- # def self.attribute(*arg,&block)
28
- def attribute(*arg,&block)
29
- (name, default) = arg
30
- short_name = name.to_s.sub(/\?/,"")
31
- self.send(:define_method, name) {
32
- if instance_variables.include? "@#{short_name}"
33
- self.instance_eval "@#{short_name}"
34
- else
35
- if block_given?
36
- instance_eval &block
12
+ def self.included(base)
13
+ base.extend(ClassMethods)
14
+ end
15
+
16
+ module ClassMethods
17
+ # Attribute is a method of declaring default values for a property.
18
+ # These default values may be either an explicit value, such as 1,
19
+ # or "dog", or they may be a block _which is evaluated at runtime_.
20
+ # As such, the block could return different values each time it is
21
+ # invoked.
22
+ #
23
+ # If the attribute is a boolean, denoted by '?', such as
24
+ # 'billable?', then the library will correctly create 'billable?'
25
+ # and 'billable=' methods.
26
+ #
27
+ # *Important*: Since the instance variable ('@billable') may not be
28
+ # defined or the attribute may represent the value returned by a
29
+ # block, it is important to access the attribute via the method
30
+ # ('billable?') as opposed to the instance variable name
31
+ # ('@billable').
32
+
33
+
34
+ def attribute(*arg,&block)
35
+ (name, default) = arg
36
+ short_name = name.to_s.sub(/\?/,"")
37
+ self.send(:define_method, name) {
38
+ if instance_variables.include? "@#{short_name}"
39
+ self.instance_eval "@#{short_name}"
37
40
  else
38
- default
41
+ if block_given?
42
+ instance_eval &block
43
+ else
44
+ default
45
+ end
39
46
  end
40
- end
41
- }
42
- self.send(:define_method, "#{short_name}="){ |value|
43
- self.instance_eval "@#{short_name} = value"
44
- }
47
+ }
48
+ self.send(:define_method, "#{short_name}="){ |value|
49
+ self.instance_eval "@#{short_name} = value"
50
+ }
51
+ end
45
52
  end
46
53
  end
47
54
  end
@@ -2,7 +2,7 @@ module AethericalUtils #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aetherical_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Williams
@@ -30,7 +30,7 @@ cert_chain:
30
30
  DG139ofzQTE=
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2008-06-16 00:00:00 -04:00
33
+ date: 2008-06-19 00:00:00 -04:00
34
34
  default_executable:
35
35
  dependencies: []
36
36
 
metadata.gz.sig CHANGED
Binary file