In this snippets with code ruby, you will see the sintax of create Structs and some Ruby 2.0+ features. The features are showed:
- **keyargs and labelled params
class MyModel < ActiveRecord::Base | |
attr_acessible :name, :value, :role_id | |
# Another strategy: multiple conditions with | |
# multiple ActiveRecord::Relation#where() method calls | |
def recipients(offset=0, limit=100, data = {}) | |
result = self.order(:id).offset(offset).limit(limit).where('value IS ?', nil) |
Here you will find examples of modules in ruby code. The structure is strong, very important and commonly used by ruby developers! Modules can be used like namespaces or mixins (adds new methods to a class).
In ruby code it's common see something like this:
MyModule::MyClass
The character :: is a namespace separator. A dot '.' can be used to, but it's not recommended.
source 'https://rubygems.org' | |
gem 'rspec', require: false, group: :test | |
gem 'simplecov', require: false, group: :test |
Author: Michel Felipe
Download and install latest mono runtime. Follow the instructions here: Install mono on Debian, Ubuntu, and derivatives
Clone the latest version from MonoDevelop github repo.
git clone git@github.com:mono/monodevelop.git
describe('npm validation logic (inquirer `when` function)', function () { | |
beforeEach(function () { | |
askName2 = proxyquire('../lib', { | |
'npm-name': function(name){ | |
return Promise.resolve(name == 'yo'); | |
} | |
}); | |
it('ask question if npm name is taken', function (done) { | |
this.inquirer.prompt.returns(Promise.resolve({name:'yo'})); |
import { DebugElement, Type } from "@angular/core"; | |
import { Predicate } from "@angular/core/src/facade/collection"; | |
import { TestBed, ComponentFixture } from '@angular/core/testing'; | |
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; | |
import { App, MenuController, NavController, Platform, Config, Keyboard, GestureController, Form, IonicModule } from 'ionic-angular'; | |
import { mockNavController, mockPlatform } from 'ionic-angular/util/mock-providers'; | |
import { ConfigMock, MenuControllerMock, KeyboardMock, GestureControllerMock, FormMock } from './mocks'; | |
/** | |
* @ngdoc object |
/** | |
* Typescript dynamic class method example | |
* | |
* REFERENCES: | |
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html | |
* @see https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Mixins.md | |
* @see http://blog.brillskills.com/2013/09/exploring-javascript-prototypes-via-typescripts-class-pattern | |
* @see https://github.com/Microsoft/TypeScript/wiki/%27this%27-in-TypeScript | |
* | |
* For this example, using IONIC 2/3 Toast component to override a method |
/** | |
* Custom task to copy all dependencies declared in you .gradle file | |
* to "libs" folder. If their dependencies contains .jar files, this will be released | |
* on aar or .jar final file of your project. | |
*/ | |
task copyLibs(type: Copy) { | |
from configurations.compile | |
into 'libs' | |
} |
/** | |
* Creates a dynamic instance of a specific class/prototype. | |
* Minor changes from initial solution shared by **Steve Fenton** | |
* | |
* WARNING: This solution don't works on Angular applications, | |
* using JIT (because the webpack don't compiles classes into window object) | |
* or AOT (js minification for production build) compilation. | |
* | |
* @see https://www.stevefenton.co.uk/2014/07/creating-typescript-classes-dynamically/ | |
*/ |