do |attrs| attrs.each do |key, value| if respond_to?("#{key}=") send("#{key}=", value) else instance_variable_set("@#{key}", value) end end end define_method(:price=) do |price_str| instance_variable_set( '@price', price_str.delete(',').to_i ) end end
= #{name.to_s.classify} klass.where(#{fk}: id) end def #{name}=(value) values.each do |value| #{name.to_s.classify}.create!(...) end end RUBY en Seems difficult internal (not actual code)
end def submit req = Net::HTTP::Post.new(@@url.path) req.set_form_data(content) Net::HTTP.start(@@url.hostname, @@url.port) do http.request(req) end end end
builder end def submit(record) CensorRequest.new( id: record.global_id, @type => @builder.call(record) ).submit end end # ---------------- censor = ContentCensor.new(:text) do |post| [post.title, post.body].join("\n\n") end censor.submit(post)