Class: Spree::Admin::Actions::ActionBuilder

Inherits:
Object
  • Object
show all
Includes:
PermissionChecks
Defined in:
app/models/spree/admin/actions/action_builder.rb

Instance Method Summary collapse

Methods included from PermissionChecks

#with_admin_ability_check, #with_availability_check, #with_create_ability_check, #with_fire_ability_check, #with_index_ability_check, #with_manage_ability_check, #with_resend_ability_check, #with_state_change_check, #with_update_ability_check

Constructor Details

#initialize(key, url) ⇒ ActionBuilder

Returns a new instance of ActionBuilder.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/spree/admin/actions/action_builder.rb', line 7

def initialize(key, url)
  @key = key
  @label_translation_key = key
  @url = url
  @icon_key = nil
  @style = ::Spree::Admin::Actions::ActionStyle::LIGHT
  @availability_checks = []
  @classes = ''
  @method = nil
  @id = nil
  @target = nil
  @data_attributes = {}
end

Instance Method Details

#build ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/spree/admin/actions/action_builder.rb', line 61

def build
  Action.new(
    @key,
    @label_translation_key,
    @url,
    @icon_key,
    @style,
    @availability_checks,
    @classes,
    @method,
    @id,
    @target,
    @data_attributes
  )
end

#with_classes(classes) ⇒ Object



31
32
33
34
# File 'app/models/spree/admin/actions/action_builder.rb', line 31

def with_classes(classes)
  @classes = classes
  self
end

#with_data_attributes(data_attributes) ⇒ Object



56
57
58
59
# File 'app/models/spree/admin/actions/action_builder.rb', line 56

def with_data_attributes(data_attributes)
  @data_attributes = data_attributes
  self
end

#with_icon_key(icon_key) ⇒ Object



26
27
28
29
# File 'app/models/spree/admin/actions/action_builder.rb', line 26

def with_icon_key(icon_key)
  @icon_key = icon_key
  self
end

#with_id(id) ⇒ Object



46
47
48
49
# File 'app/models/spree/admin/actions/action_builder.rb', line 46

def with_id(id)
  @id = id
  self
end

#with_label_translation_key(key) ⇒ Object



21
22
23
24
# File 'app/models/spree/admin/actions/action_builder.rb', line 21

def with_label_translation_key(key)
  @label_translation_key = key
  self
end

#with_method(method) ⇒ Object



41
42
43
44
# File 'app/models/spree/admin/actions/action_builder.rb', line 41

def with_method(method)
  @method = method
  self
end

#with_style(style) ⇒ Object



36
37
38
39
# File 'app/models/spree/admin/actions/action_builder.rb', line 36

def with_style(style)
  @style = style
  self
end

#with_target(target) ⇒ Object



51
52
53
54
# File 'app/models/spree/admin/actions/action_builder.rb', line 51

def with_target(target)
  @target = target
  self
end