Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/aws/s3/extensions.rb
Instance Method Summary collapse
-
#const_missing_from_s3_library(sym) ⇒ Object
(also: #const_missing)
Transforms MarcelBucket into.
- #constant(name, value) ⇒ Object
- #memoized(method_name) ⇒ Object
Instance Method Details
#const_missing_from_s3_library(sym) ⇒ Object Also known as: const_missing
113 114 115 116 117 118 119 120 121 |
# File 'lib/aws/s3/extensions.rb', line 113 def const_missing_from_s3_library(sym) if sym.to_s =~ /^(\w+)(Bucket|S3Object)$/ const = const_set(sym, Class.new(AWS::S3.const_get($2))) const.current_bucket = $1.underscore const else const_missing_not_from_s3_library(sym) end end |
#constant(name, value) ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/aws/s3/extensions.rb', line 97 def constant(name, value) unless const_defined?(name) const_set(name, value) module_eval(<<-EVAL, __FILE__, __LINE__) def self.#{name.to_s.downcase} #{name.to_s} end EVAL end end |
#memoized(method_name) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/aws/s3/extensions.rb', line 85 def memoized(method_name) original_method = "unmemoized_#{method_name}_#{Time.now.to_i}" alias_method original_method, method_name module_eval(<<-EVAL, __FILE__, __LINE__) def #{method_name}(reload = false, *args, &block) memoize(reload) do send(:#{original_method}, *args, &block) end end EVAL end |