define_method
可以帮助我们动态的,快速的定义多个方法;比如有这样一个类:
class Post
attr_accessor :title, :content, :state
def initialize(title, content, state = :draft)
@title, @content, @state = title, content, state
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
appVersion: Ember.VERSION, | |
}); |
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
} |
import Ember from 'ember'; | |
import { task, waitForEvent } from 'ember-concurrency'; | |
const { Evented, Controller } = Ember; | |
export default Controller.extend(Evented, { | |
myTask: task(function* () { | |
while (true) { | |
let payload = yield waitForEvent(this, 'message'); | |
this.get('messages').pushObject(payload); | |
} |
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
} |
This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.
For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
bar: 0, | |
actions: { | |
change() { | |
// if comment out this line, mutation will be updated in template properly | |
this.toggleProperty('foo'); | |
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
activate() { | |
document.body.classList.add('standard'); | |
} | |
}); |
import Ember from 'ember'; | |
const { Controller } = Ember; | |
export default class ApplicationController extends Controller { | |
constructor() { | |
super(...arguments); | |
this.application_name = '<code>as</code> pattern'; | |
} | |
} |
import Ember from 'ember'; | |
const { Controller } = Ember; | |
export default class ApplicationController extends Controller { | |
constructor() { | |
super(); | |
this.application_name = 'Double Loop'; | |
} | |
} |