Class: PluckMap::StructuredAttribute

Inherits:
Attribute
  • Object
show all
Defined in:
lib/pluck_map/structured_attribute.rb

Direct Known Subclasses

Relationships::Base

Instance Attribute Summary collapse

Attributes inherited from Attribute

#block, #id, #indexes, #model, #name, #selects, #value

Instance Method Summary collapse

Methods inherited from Attribute

#==, #apply, #eql?, #exec, #hash, #preload!, #to_ruby, #value?, #values

Constructor Details

#initialize(attribute_name, model, block, options = {}) ⇒ StructuredAttribute

Returns a new instance of StructuredAttribute.



7
8
9
10
11
# File 'lib/pluck_map/structured_attribute.rb', line 7

def initialize(attribute_name, model, block, options={})
  @attributes = AttributeBuilder.build(model: model, &block)
  options = options.slice(:as).merge(select: build_select, map: build_map)
  super(attribute_name, model, options)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/pluck_map/structured_attribute.rb', line 5

def attributes
  @attributes
end

Instance Method Details

#nested?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/pluck_map/structured_attribute.rb', line 17

def nested?
  true
end

#will_map?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/pluck_map/structured_attribute.rb', line 13

def will_map?
  attributes.any?(&:will_map?)
end