has_options 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/has_options.gemspec +1 -1
- data/lib/has_options/has_options.rb +4 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
data/has_options.gemspec
CHANGED
@@ -5,6 +5,10 @@ module HasOptionsHash
|
|
5
5
|
end
|
6
6
|
|
7
7
|
module ClassMethods
|
8
|
+
def acts_as_options
|
9
|
+
validates_presence_of :name, :association_type
|
10
|
+
end
|
11
|
+
|
8
12
|
def has_options(options={})
|
9
13
|
configuration = { :option_model => "Option", :association_name => :options}
|
10
14
|
configuration.update(options) if options.is_a?(Hash)
|
@@ -14,7 +18,6 @@ module HasOptionsHash
|
|
14
18
|
option_model = configuration[:option_model]
|
15
19
|
table_name = option_model.constantize.table_name
|
16
20
|
has_many association_name, :class_name => configuration[:option_model], :as => :entity, :dependent => :destroy, :conditions => {:association_type => association_name}
|
17
|
-
validates_presence_of :name, :association_type
|
18
21
|
|
19
22
|
class_eval <<-EOV
|
20
23
|
define_method "find_#{singular_association}_value" do |name|
|