9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/polyblock/has_polyblock.rb', line 9
def has_polyblock(name, options={})
defaults = Polyblock::Block::DEFAULTS
settings = defaults.deep_merge(options)
has_one name, -> { where(:name => name) }, settings[:association]
accepts_nested_attributes_for name, settings[:nested_attributes]
cattr_accessor "#{name}_settings".to_sym
send("#{name}_settings=".to_sym, settings)
after_initialize do
send("build_#{name}".to_sym) if send(name.to_sym).nil?
end
include Polyblock::HasPolyblock::LocalInstanceMethods
end
|