Class: ActionBlocks::MountedFormBuilder
- Inherits:
-
BlockType
- Object
- BaseBuilder
- BlockType
- ActionBlocks::MountedFormBuilder
- Defined in:
- lib/action_blocks/builders/workspace_builder.rb
Instance Attribute Summary
Attributes inherited from BaseBuilder
Instance Method Summary collapse
-
#after_load ⇒ Object
validate :validate_mounted_to def validate_mounted_to return unless [:dashboard, :subspace].include?(@mounted_to) errors.add(:mounted_to, “#@[email protected] #BlockType#type must be mounted to :dashboard or :subspace but #@mounted_to@mounted_to.inspect was specified.”) end.
- #before_build(parent, *args) ⇒ Object
- #hashify(user) ⇒ Object
Methods inherited from BlockType
Methods inherited from BaseBuilder
#after_build, 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 Method Details
#after_load ⇒ Object
validate :validate_mounted_to def validate_mounted_to
return unless [:dashboard, :subspace].include?(@mounted_to)
errors.add(:mounted_to, "#{@parent.key} #{type} must be mounted to :dashboard or :subspace but #{@mounted_to.inspect} was specified.")
end
validate :validate_mount_point_matches_model def validate_mount_point_matches_model
# TODO
end
262 263 264 265 266 267 268 269 270 |
# File 'lib/action_blocks/builders/workspace_builder.rb', line 262 def after_load # After load is called after all blocks are in the store if form.model.id == @subspace.model.try(:id) @mounted_to = :subspace end if form.model.id == @dashboard.model.try(:id) @mounted_to = :dashboard end end |
#before_build(parent, *args) ⇒ Object
244 245 246 247 248 249 |
# File 'lib/action_blocks/builders/workspace_builder.rb', line 244 def before_build(parent, *args) @id = args[0] @dashboard = parent @subspace = @dashboard.subspace @form_key = "form-#{@id}" end |
#hashify(user) ⇒ Object
272 273 274 275 276 277 278 |
# File 'lib/action_blocks/builders/workspace_builder.rb', line 272 def hashify(user) { type: :mounted_form, form_key: @form_key, mounted_to: @mounted_to } end |