turbo_boost-commands 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of turbo_boost-commands might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19da2f1ce6b12b8a783a91505ad75930e54f3efe8d760bfd1b081c3e665ce76f
4
- data.tar.gz: f410b78f5d8691f923afe0c40b42eefb9d7b296b200a389a14c543b2414584b7
3
+ metadata.gz: 31d86b3d0bcbbfefda466f5981d4268a593bab8c15ff9eecc8536a780f4cdbcf
4
+ data.tar.gz: 4a3c0a02dba994d270cab58adf1c027178790793efc0595ee9cb57e93c6ffba8
5
5
  SHA512:
6
- metadata.gz: a774c61f0e92124a6de3ac6c4f301ea86c49f5741f680727803c4743750e11d2bc7aa8da0471ba30fb021b342a23d8fae79e449a6f1226c72cc967ed22af772b
7
- data.tar.gz: 600f573dcb569560efe841db6581f48f568a84598a0b550a656c5b744ffa6fa084f15ae72cd714fc4edfdaf68eb47e8908298a89714e242100f0b91c29ee6fb5
6
+ metadata.gz: e56a339c7bb7e0f3e636127fdc18ae9df28c3d1e5c6bd762d886353111a88f6d50f0a63911d0b06bfe8cc5b7794e164f4194769d866be1199f27e8b4164dad0d
7
+ data.tar.gz: aaca1ef1eb38fdb7c644dc13f4b5707d622da3f15c8a161e762b9c5ba9329b8e5eb7cfe2ae6e98f81f0cc67146eb71123adbf60c0ba28705ef5214c2fa1f9d56
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  </h1>
9
9
  <p align="center">
10
10
  <a href="http://blog.codinghorror.com/the-best-code-is-no-code-at-all/">
11
- <img alt="Lines of Code" src="https://img.shields.io/badge/loc-1481-47d299.svg" />
11
+ <img alt="Lines of Code" src="https://img.shields.io/badge/loc-1490-47d299.svg" />
12
12
  </a>
13
13
  <a href="https://codeclimate.com/github/hopsoft/turbo_boost-commands/maintainability">
14
14
  <img src="https://api.codeclimate.com/v1/badges/fe1162a742fe83a4fdfd/maintainability" />
@@ -9,18 +9,20 @@ require_relative "command_callbacks"
9
9
  # Commands are executed via a before_action in the Rails controller lifecycle.
10
10
  # They have access to the following methods and properties.
11
11
  #
12
- # * controller .................. The Rails controller processing the HTTP request
13
- # * css_id_selector ............. Returns a CSS selector for an element `id` i.e. prefixes with `#`
14
- # * dom_id ...................... The Rails dom_id helper
15
- # * dom_id_selector ............. Returns a CSS selector for a dom_id
16
- # * element ..................... A struct that represents the DOM element that triggered the command
17
- # * morph ....................... Appends a Turbo Stream to morph a DOM element
18
- # * params ...................... Commands specific params (frame_id, element, etc.)
19
- # * render ...................... Renders Rails templates, partials, etc. (doesn't halt controller request handling)
20
- # * renderer .................... An ActionController::Renderer
21
- # * state ....................... An object that stores ephemeral `state`
22
- # * turbo_stream ................ A Turbo Stream TagBuilder
23
- # * turbo_streams ............... A list of Turbo Streams to append to the response (also aliased as streams)
12
+ # * controller ...................... The Rails controller processing the HTTP request
13
+ # * convert_to_instance_variables ... Converts a Hash to instance variables
14
+ # * css_id_selector ................. Returns a CSS selector for an element `id` i.e. prefixes with `#`
15
+ # * dom_id .......................... The Rails dom_id helper
16
+ # * dom_id_selector ................. Returns a CSS selector for a dom_id
17
+ # * element ......................... A struct that represents the DOM element that triggered the command
18
+ # * morph ........................... Appends a Turbo Stream to morph a DOM element
19
+ # * params .......................... Commands specific params (frame_id, element, etc.)
20
+ # * render .......................... Renders Rails templates, partials, etc. (doesn't halt controller request handling)
21
+ # * renderer ........................ An ActionController::Renderer
22
+ # * state ........................... An object that stores ephemeral `state`
23
+ # * transfer_instance_variables ..... Transfers all instance variables to another object
24
+ # * turbo_stream .................... A Turbo Stream TagBuilder
25
+ # * turbo_streams ................... A list of Turbo Streams to append to the response (also aliased as streams)
24
26
  #
25
27
  # They also have access to the following class methods:
26
28
  #
@@ -90,11 +92,24 @@ class TurboBoost::Commands::Command
90
92
  @turbo_streams = Set.new
91
93
  end
92
94
 
93
- # Abdstract `perform` method, overridde in subclassed commands
95
+ # Abstract `perform` method, overridde in subclassed commands
94
96
  def perform
95
97
  raise NotImplementedError, "#{self.class.name} must implement the `perform` method!"
96
98
  end
97
99
 
100
+ # Converts a Hash to instance variables
101
+ def convert_to_instance_variables(hash = {})
102
+ return unless hash.present?
103
+ hash.each { |key, value| instance_variable_set :"@#{key}", value }
104
+ end
105
+
106
+ # Transfers all instance variables to another object
107
+ def transfer_instance_variables(object)
108
+ instance_variables.each do |name|
109
+ object.instance_variable_set name, instance_variable_get(name)
110
+ end
111
+ end
112
+
98
113
  def dom_id_selector(...)
99
114
  css_id_selector dom_id(...)
100
115
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TurboBoost
4
4
  module Commands
5
- VERSION = "0.0.5"
5
+ VERSION = "0.0.6"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_boost-commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Hopkins (hopsoft)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-05 00:00:00.000000000 Z
11
+ date: 2023-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails