lib/multi_sync/resource.rb in multi_sync-0.0.3 vs lib/multi_sync/resource.rb in multi_sync-0.0.4
- old
+ new
@@ -5,12 +5,12 @@
module MultiSync
class Resource
include Comparable
include Virtus.model
- attribute :path_with_root, Pathname
- attribute :path_without_root, Pathname
+ attribute :path_with_root, MultiSync::Attributes::Pathname
+ attribute :path_without_root, MultiSync::Attributes::Pathname
attribute :etag, String, default: :determine_etag, lazy: true
attribute :mtime, Time, default: :determine_mtime, lazy: true
attribute :content_length, Numeric, default: :determine_content_length, lazy: true
attribute :content_type, String, default: :determine_content_type, lazy: true
@@ -41,9 +41,15 @@
AWS_ATTRIBUTES.each do |attribute_hash|
def_attribute_hash = {}
def_attribute_hash[:default] = attribute_hash[:default] unless attribute_hash[:default].nil?
def_attribute_hash[:required] = attribute_hash[:required] unless attribute_hash[:required].nil?
send(:attribute, attribute_hash[:name], attribute_hash[:type], def_attribute_hash)
+ end
+
+ def initialize(*args)
+ super
+ rescue Virtus::CoercionError => e
+ raise ArgumentError, e.message
end
def hash
path_without_root.hash
end