lib/swift/attribute.rb in swift-0.6.1 vs lib/swift/attribute.rb in swift-0.7.0
- old
+ new
@@ -1,25 +1,17 @@
module Swift
+ #--
+ # NOTE: Default method is defined in the extension.
class Attribute
attr_reader :name, :field, :key, :serial
def initialize scheme, name, options = {}
- @name = name
- @default = options.fetch(:default, nil)
- @field = options.fetch(:field, name)
- @key = options.fetch(:key, false)
- @serial = options.fetch(:serial, false)
+ @name = name
+ @default = options.fetch(:default, nil)
+ @field = options.fetch(:field, name)
+ @key = options.fetch(:key, false)
+ @serial = options.fetch(:serial, false)
define_scheme_methods(scheme)
- end
-
- def default
- if @default.respond_to?(:call)
- @default.call
- elsif Swift.special_constant?(@default)
- @default
- else
- @default.dup
- end
end
def define_scheme_methods scheme
scheme.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{name}; tuple.fetch(:#{field}, nil) end