Class: ActionBlocks::DashboardBuilder

Inherits:
BaseBuilder show all
Defined in:
lib/action_blocks/builders/workspace_builder.rb

Instance Attribute Summary collapse

Attributes inherited from BaseBuilder

#dsl_delegate, #id

Instance Method Summary collapse

Methods inherited from BaseBuilder

#after_build, #after_load, array_fields, block_type, builds, builds_many, delegate_class, #evaluate, #freeze, includes_scheme_helpers, #initialize, #is_block?, #key, references, sets, sets_many, #ui_reference, #valid?

Constructor Details

This class inherits a constructor from ActionBlocks::BaseBuilder

Instance Attribute Details

#subspaceObject

Returns the value of attribute subspace.



200
201
202
# File 'lib/action_blocks/builders/workspace_builder.rb', line 200

def subspace
  @subspace
end

#workspaceObject

Returns the value of attribute workspace.



200
201
202
# File 'lib/action_blocks/builders/workspace_builder.rb', line 200

def workspace
  @workspace
end

Instance Method Details

#before_build(parent, *args) ⇒ Object



208
209
210
211
212
213
214
215
216
# File 'lib/action_blocks/builders/workspace_builder.rb', line 208

def before_build(parent, *args)
  @subspace = parent
  @workspace = @subspace.workspace
  @category = args[0]
  @title = @category.to_s.titleize
  if args[1]
    @model_key = "model-#{args[1]}"
  end
end

#has_unique_dashletsObject



220
221
222
223
224
225
226
227
# File 'lib/action_blocks/builders/workspace_builder.rb', line 220

def has_unique_dashlets
  @dashlets.group_by(&:key).each do |k, dashlets|
      if(dashlets.length > 1)
        d = dashlets.first
        errors.add(:dashlets, "Duplicate #{d.type.inspect} added to dashboard #{workspace.id}/#{subspace.id}/#{id} with id #{d.id.inspect}")
      end
  end
end

#hashify(user) ⇒ Object



229
230
231
232
233
234
235
236
237
# File 'lib/action_blocks/builders/workspace_builder.rb', line 229

def hashify(user)
  {
    key: key,
    title: @title,
    model: @model_key,
    category: @category,
    dashlet_keys: @dashlets.map(&:key)
  }
end