Does LESS have an “extend” feature?

Yes, Less.js introduced extend in v1.4.0. :extend() Rather than implementing the at-rule (@extend) syntax used by SASS and Stylus, LESS implemented the pseudo-class syntax, which gives LESS’s implementation the flexibility to be applied either directly to a selector itself, or inside a statement. So both of these will work: .sidenav:extend(.nav) {…} or .sidenav { &:extend(.nav); … Read more

Extending an existing jQuery function

Sure… Just save a reference to the existing function, and call it: (function($) { // maintain a reference to the existing function var oldcss = $.fn.css; // …before overwriting the jQuery extension point $.fn.css = function() { // original behavior – use function.apply to preserve context var ret = oldcss.apply(this, arguments); // stuff I will … Read more

Difference between jQuery.extend and jQuery.fn.extend?

jQuery.extend is used to extend any object with additional functions, but jQuery.fn.extend is used to extend the jQuery.fn object, which in fact adds several plugin functions in one go (instead of assigning each function separately). jQuery.extend: var obj = { x: function() {} } jQuery.extend(obj, { y: function() {} }); // now obj is an … Read more

What is the difference between include and extend in Ruby?

extend – adds the specified module’s methods and constants to the target’s metaclass (i.e. the singleton class) e.g. if you call Klazz.extend(Mod), now Klazz has Mod’s methods (as class methods) if you call obj.extend(Mod), now obj has Mod’s methods (as instance methods), but no other instance of of obj.class has those methods added. extend is … Read more

Rails extending ActiveRecord::Base

There are several approaches : Using ActiveSupport::Concern (Preferred) Read the ActiveSupport::Concern documentation for more details. Create a file called active_record_extension.rb in the lib directory. require ‘active_support/concern’ module ActiveRecordExtension extend ActiveSupport::Concern # add your instance methods here def foo “foo” end # add your static(class) methods here class_methods do #E.g: Order.top_ten def top_ten limit(10) end end … Read more