Class: Praxis::Blueprint::DSLCompiler

Inherits:
Attributor::HashDSLCompiler
  • Object
show all
Defined in:
lib/praxis/blueprint.rb

Instance Method Summary collapse

Instance Method Details

#group(name, **options, &block) ⇒ Object

group DSL is meant to group a subset of attributes in the media type (instead of presenting all things flat) It will create a normal attribute, but as a BlueprintAttributeGroup, rather than a Struct, so that we can more easily pass in objects that respond to the right methods, and avoid a Struct loading them all in hash keys. For example, if there are computationally intensive attributes in the subset, we want to make sure those functions aren’t invoked by just merely loading, and only really invoked when we’ve asked to render them It takes the name of the group, and passes the attributes block that needs to be a subset of the MediaType where the group resides



12
13
14
15
# File 'lib/praxis/blueprint.rb', line 12

def group(name, **options, &block)
  # Pass the reference to the target type by default. But allow overriding it if needed
  attribute(name, Praxis::BlueprintAttributeGroup.for(target), **{ reference: target }.merge(options), &block)
end