Skip to content

Commit

Permalink
更新attribute_array
Browse files Browse the repository at this point in the history
  • Loading branch information
afly committed Feb 12, 2012
1 parent 1a48eb4 commit 02c567b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/bitmask_attributes/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,14 @@ def #{attribute}
@#{attribute}.size == 1 ? @#{attribute}.first : @#{attribute}
end
def #{attribute}_array
@#{attribute}_array ||= BitmaskAttributes::ValueProxy.new(self, :#{attribute}, &self.class.bitmask_definitions[:#{attribute}].extension)
end
)
end

def override_setter_on(model)
model.class_eval %(
def #{attribute}=(raw_value)
values = raw_value.kind_of?(Array) ? raw_value : [raw_value]
self.#{attribute}_array.replace(values.reject(&:blank?))
@#{attribute}.replace(values.reject(&:blank?))
end
)
end
Expand Down

0 comments on commit 02c567b

Please sign in to comment.