Erlang/OTP 18 RC-1
Elixir 1.1.0-dev
-
new
-
put
- 100 elements
MapSet: 10000000 0.16 µs/op
| module VirtualAttributes | |
| extend ActiveSupport::Concern | |
| class VirtualAttribute < Struct.new(:klass); end | |
| module ClassMethods | |
| def attr_virtual(*attrs) | |
| options = attrs.extract_options! | |
| attrs.each do |attr| |
| module VirtualAttributes | |
| extend ActiveSupport::Concern | |
| module ClassMethods | |
| def attr_virtual(*attrs) | |
| options = attrs.extract_options! | |
| attrs.each do |attr| | |
| class_eval do | |
| send("attr_accessor", attr) |
| module VirtualAttributes | |
| extend ActiveSupport::Concern | |
| class VirtualAttribute | |
| attr_reader :name, :type | |
| def initilaize(name, type = :string) | |
| @name = name | |
| @type = type | |
| end |
| % rails g model Hotel | |
| % rails g model Hotel::Translation # or hotel/translation |
| <%= form_for @post do |f| %> | |
| <%= f.text_field :title, value: 'It will never change', readonly: true %> | |
| <%= f.text_field :description, value: 'You will not see it in params', disabled: true %> | |
| <%= f.button :submit %> | |
| <% end %> | |
| <!-- params[:post] => { "title"=>"It will never change" } --> |
| class Article < ActiveRecord::Base # Product class is similar | |
| belongs_to :user | |
| has_many :media, as: :ownable | |
| with_options through: :media, source: :representable do |assn| | |
| assn.has_many :videos, source_type: 'Video' | |
| assn.has_many :images, source_type: 'Image' | |
| end | |
| end |
| <%= simple_form_for(@product) do |f| %> | |
| <%= f.input :title %> <!-- string --> | |
| <%= f.input :description %> <!-- text --> | |
| <%= yield(f) if block_given? %> | |
| <%= f.button :submit %> | |
| <% end %> |
| //= require jquery | |
| //= require jquery_ujs | |
| $(function() { | |
| var source = new EventSource('/stream'); | |
| source.addEventListener('counter', function(e) { | |
| $('body').after(e.data + '<br />'); | |
| }); | |
| }); |
| require 'sinatra' | |
| set server: :thin | |
| get '/' do | |
| erb :welcome | |
| end | |
| get '/stream', provides: 'text/event-stream' do | |
| stream do |out| | |
| loop do |
Erlang/OTP 18 RC-1
Elixir 1.1.0-dev
new
put
MapSet: 10000000 0.16 µs/op