Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
davydovanton committed Sep 27, 2016
1 parent 64cb6fe commit a82c10c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/shallow_attributes.rb
Expand Up @@ -7,6 +7,8 @@
#
# @since 0.1.0
module ShallowAttributes
class NotPresentError < StandardError; end

include InstanceMethods

# Including ShallowAttributes class methods to specific class
Expand Down
8 changes: 8 additions & 0 deletions lib/shallow_attributes/instance_methods.rb
Expand Up @@ -31,6 +31,14 @@ module InstanceMethods
# @since 0.1.0
def initialize(attrs = {})
@attributes = attrs.delete_if { |key, _| !default_values.key?(key) }

unless self.class.presents_attributes.empty?
@attributes.each do |key, _|
raise StandardError if self.class.presents_attributes.include?(key)
end
end


define_attributes
define_default_attributes
end
Expand Down

0 comments on commit a82c10c

Please sign in to comment.