Class: Bs5::CollapseService

Inherits:
Object
  • Object
show all
Defined in:
app/service/bs5/collapse_service.rb

Constant Summary collapse

CONTROLS_ERR_MSG =
'Please provide either a `controls` option' \
' containing the id of the collapsible element' \
' or an ID selector as `target` options.'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expanded: false, target: nil, controls: nil) ⇒ CollapseService

Returns a new instance of CollapseService.



13
14
15
16
17
# File 'app/service/bs5/collapse_service.rb', line 13

def initialize(expanded: false, target: nil, controls: nil)
  @expanded = expanded
  @target = target
  @controls = controls
end

Instance Attribute Details

#controlsObject (readonly)

Returns the value of attribute controls.



11
12
13
# File 'app/service/bs5/collapse_service.rb', line 11

def controls
  @controls
end

#expandedObject (readonly)

Returns the value of attribute expanded.



11
12
13
# File 'app/service/bs5/collapse_service.rb', line 11

def expanded
  @expanded
end

#targetObject (readonly)

Returns the value of attribute target.



11
12
13
# File 'app/service/bs5/collapse_service.rb', line 11

def target
  @target
end

Instance Method Details

#to_hashObject



19
20
21
22
23
24
# File 'app/service/bs5/collapse_service.rb', line 19

def to_hash
  {
    data: data_options,
    aria: aria_options
  }
end