Class: CableReady::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/cable_ready/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Channel

Example Operations Payload:

{

# DOM Events ..................................................................................................

dispatch_event: [{
  name:     "string",
  detail:   "object",
  selector: "string",
}, ...],

# Element Mutations ...........................................................................................

inner_html: [{
  selector: "string",
  focusSelector: "string",
  html:     "string"
}, ...],

text_content: [{
  selector: "string",
  text:     "string"
}, ...]

insert_adjacent_html: [{
  selector: "string",
  focusSelector: "string",
  position: "string",
  html:     "string"
}, ...],

insert_adjacent_text: [{
  selector: "string",
  position: "string",
  text:     "string"
}, ...],

remove: [{
  selector: "string",
  focusSelector: "string,
}, ...],

replace: [{
  selector: "string",
  focusSelector: "string",
  html:     "string"
}, ...],

set_value: [{
  selector: "string",
  value:    "string"
}, ...],

# Attribute Mutations .........................................................................................

set_attribute: [{
  selector: "string",
  name:     "string",
  value:    "string"
}, ...],

remove_attribute: [{
  selector: "string",
  name:     "string"
}, ...],

# CSS Class Mutations .........................................................................................

add_css_class: [{
  selector: "string",
  name:     "string"
}, ...],

remove_css_class: [{
  selector: "string",
  name:     "string"
}, ...],

# Dataset Mutations ...........................................................................................

set_dataset_property: [{
  selector: "string",
  name:     "string",
  value:    "string"
}, ...],

}



91
92
93
94
# File 'lib/cable_ready/channel.rb', line 91

def initialize(name)
  @name = name
  @operations = stub
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/cable_ready/channel.rb', line 3

def name
  @name
end

#operationsObject (readonly)

Returns the value of attribute operations.



3
4
5
# File 'lib/cable_ready/channel.rb', line 3

def operations
  @operations
end

Instance Method Details

#add_css_class(options = {}) ⇒ Object



140
141
142
# File 'lib/cable_ready/channel.rb', line 140

def add_css_class(options={})
  operations[:add_css_class] << options
end

#clearObject



96
97
98
# File 'lib/cable_ready/channel.rb', line 96

def clear
  @operations = stub
end

#dispatch_event(options = {}) ⇒ Object



100
101
102
# File 'lib/cable_ready/channel.rb', line 100

def dispatch_event(options={})
  operations[:dispatch_event] << options
end

#inner_html(options = {}) ⇒ Object



104
105
106
# File 'lib/cable_ready/channel.rb', line 104

def inner_html(options={})
  operations[:inner_html] << options
end

#insert_adjacent_html(options = {}) ⇒ Object



112
113
114
# File 'lib/cable_ready/channel.rb', line 112

def insert_adjacent_html(options={})
  operations[:insert_adjacent_html] << options
end

#insert_adjacent_text(options = {}) ⇒ Object



116
117
118
# File 'lib/cable_ready/channel.rb', line 116

def insert_adjacent_text(options={})
  operations[:insert_adjacent_text] << options
end

#remove(options = {}) ⇒ Object



120
121
122
# File 'lib/cable_ready/channel.rb', line 120

def remove(options={})
  operations[:remove] << options
end

#remove_attribute(options = {}) ⇒ Object



136
137
138
# File 'lib/cable_ready/channel.rb', line 136

def remove_attribute(options={})
  operations[:remove_attribute] << options
end

#remove_css_class(options = {}) ⇒ Object



144
145
146
# File 'lib/cable_ready/channel.rb', line 144

def remove_css_class(options={})
  operations[:remove_css_class] << options
end

#replace(options = {}) ⇒ Object



124
125
126
# File 'lib/cable_ready/channel.rb', line 124

def replace(options={})
  operations[:replace] << options
end

#set_attribute(options = {}) ⇒ Object



132
133
134
# File 'lib/cable_ready/channel.rb', line 132

def set_attribute(options={})
  operations[:set_attribute] << options
end

#set_dataset_property(options = {}) ⇒ Object



148
149
150
# File 'lib/cable_ready/channel.rb', line 148

def set_dataset_property(options={})
  operations[:set_dataset_property] << options
end

#set_value(options = {}) ⇒ Object



128
129
130
# File 'lib/cable_ready/channel.rb', line 128

def set_value(options={})
  operations[:set_value] << options
end

#text_content(options = {}) ⇒ Object



108
109
110
# File 'lib/cable_ready/channel.rb', line 108

def text_content(options={})
  operations[:text_content] << options
end