...a setter (when it gets the new value as an argument): $scope.name = function(newName) { return angular.isDefined(newName) ? (_name = newName) : _name; } You need to bind this function with ng-model and...
...angular.module('getterSetterExample', []) .controller('ExampleController', ['$scope', function($scope) { var _name = 'Brian'; $scope.user = { name: function(newName) { return angular.isDefined(newName) ? (_name = newName) : _name...
...this in your uploaders already. end def remove_empty_container_directory(dir = store_dir) return unless Dir.empty?(dir) Dir.delete(dir) remove_empty_container_directory(File.dirname(dir)) end end
...function. Where promiseState() becomes useful is when writing unit tests for a function that returns a promise. Let's say we write a promise-based variant of setTimeout(): function setTimer...
return new Promise(resolve, reject) { setTimeout(resolve, delay) } } We would use it like this: setTimer(300).then(function() {...
Here is a test for setTimer() that uses promiseState(): describe('setTimer...
...version_appendix(version) Versionomy.parse(version) end def self.major_version_change?(version_1, version_2) return false if version_1.blank? || version_2.blank? parse_major_version(version_1) != parse_major_version(version_2)
...on the last argument to that method, before assigning optional arguments. If to_hash returns an instance of Hash, the hash is taken as keyword arguments to that method.
...it most likely will), Ruby will raise ArgumentError. Bah. (If to_hash does not return a Hash, assignment will work as expected – but this should actually never happen.)
Usually, Unpoly compiler destructors are returned from the compiler function. However, when using async compiler functions, you can not register destructors via return. This will not work: up.compiler('my-example...
...async (element) => { await something return function onDestroy() { // ... } }) Instead, use up.destructor: up.compiler('my-example', async (element) => { await something up.destructor(element, function onDestroy() { // ... }) }) However, note that your element might be removed from...
...is probably \s. It matches the following whitespace characters: " " (space) \n (newline) \r (carriage return) \t (tab) \f (form feed/page break) However, in some cases these may not be good...
...option --ignore-app-not-running and due to that the command will exit with return code 0. With the next request to your application passenger will start your application based...
...def inline!(version) # It is recommended to watch for a feature flag, see below. return version unless Rails.config.feature_inline_email_images # `attachments` is provided by Rails, see the linked documentation...
attachments[version.url] end This helper expects a Carrierwave version as in input. It returns an object that represents the attachment and responds to the #url method. Mailer view:
...entire layout will probably also contain that text (in a descendant) and Capybara will return it. See Find the innermost DOM element that contains a given string. Footnotes
...result.to_d(0) is the required precision parameter, which is applied to the BigDecimal return value. Using Rationals has some pitfalls you should be aware of: Multiplying a Rational with...
Furthermore, you can add a "modifier" to the percent notation to control the return type of the expression: %s Symbol %i Array of Symbols %q String
if [ $count -eq 0 ]; then echo "No files created or found to copy." return 1 fi printf "$uri_list" | head -c -1 | xclip -selection clipboard -t text/uri-list echo "📋 Copied...
...offense for rule "space-before-blocks" [#180343876] Fix ESLint offense for rule "no-useless-return" [#180343876] Add ESLint without any offenses
...rescue ActionController::ParameterMissing {} end def note_scope # Restrict what the user may access by returning a scope with conditions. Note.all end def load_notes @notes ||= note_scope .strict_loading # Raise...
...preloaded will raise an ActiveRecord::StrictLoadingViolationError. There is a private method #note_params that returns a permitted attributes hash that can be set through the #update and #create actions.
...The more tests you already have, the less useful an additional test becomes ("Diminishing returns"). Tests sometimes fail even though the code is fine, especially when the test is coupled...
Ruby's __FILE__ keyword returns the path to the current file. On popular for this are Ruby binaries: #!/usr/bin/env ruby $LOAD_PATH << File.expand_path('../../lib', __FILE__) require 'my_cli'
Due to the way we setup Jasmine tests in our projects, you may run into various errors when Jasmine boots...
...it will wait for any beforeunload to be handled before e.g. a page.refresh statement returns. That that this also applies to wrapped calls like accept_confirm { page.refresh }. Recommendation
...which's expected name is hard coded. A popular example is extension_allowlist, which returns an array of strings and let's you only upload files that have a filename...
...Project.find_each do |project| project.recalculate_statistics! end Both find_in_batches and find_each return records ordered by ID because they need to be able to iterate in batches. Modern...
...classic "unit tests" where you instantiate an object, call a method and observe its return value or side effects. Your MovieDB already uses the gem rspec-rails which has many...
If the given ID was not found, a redirect to /movies is returned. The HTTP status 307 is used for the redirect. The movies index shows a flash...
...Yarn requires Node.js 4.0 or higher to be installed. Check if command -v "node" returns a path and you load NVM before Yarn. This could look like this:
...your browser window for 10 seconds. The reason is that evaluate_script will always return a result. The return value will be converted back to Ruby objects, which in case...