class Beret::BlockSet
Attributes
block_json[R]
Public Class Methods
new(block_json)
click to toggle source
# File lib/beret/block_set.rb, line 4 def initialize(block_json) @block_json = block_json end
Public Instance Methods
blocks()
click to toggle source
# File lib/beret/block_set.rb, line 29 def blocks @blocks ||= block_json.map do |block| Block.new(block) end end
find(field_name, options={}) { |value, block| ... }
click to toggle source
# File lib/beret/block_set.rb, line 8 def find(field_name, options={}) results = Search.new(blocks, field_name, options).results if block_given? results.each do |result| yield result.value, result.block end end results end
to_json()
click to toggle source
# File lib/beret/block_set.rb, line 35 def to_json blocks.map(&:to_json) end
update(field_name, options={}) { |value, block| ... }
click to toggle source
# File lib/beret/block_set.rb, line 20 def update(field_name, options={}) results = find(field_name, options) results.each do |result| new_value = yield result.value, result.block result.block.update_attribute(field_name, new_value) end end