Module: ColonelKurtz::Model::Blockable
- Defined in:
- lib/colonel_kurtz/model/blockable.rb
Instance Method Summary collapse
Instance Method Details
#has_blocks(*fields) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/colonel_kurtz/model/blockable.rb', line 7 def has_blocks(*fields) fields.each do |field| define_method "#{field}_blocks" do begin content = send(field) if content.is_a?(String) content = JSON.parse(content) end content.map { |data| ColonelKurtz::Block.new(data) } rescue [] # TODO error handling end end end end |