Module: Polyblock::HasPolyblock::ClassMethods
- Defined in:
- lib/polyblock/has_polyblock.rb
Instance Method Summary collapse
Instance Method Details
#has_polyblock(name, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/polyblock/has_polyblock.rb', line 9 def has_polyblock(name, ={}) defaults = Polyblock::Block::DEFAULTS settings = defaults.deep_merge() has_one name, -> { where(:name => name) }, settings[:association] accepts_nested_attributes_for name, settings[:nested_attributes] after_initialize do send("build_#{name}".to_sym) if send(name.to_sym).nil? send(name.to_sym).settings = settings end include Polyblock::HasPolyblock::LocalInstanceMethods end |
#has_polyblock?(name) ⇒ Boolean
27 28 29 |
# File 'lib/polyblock/has_polyblock.rb', line 27 def has_polyblock?(name) self.polyblocks.include?(name) end |