extend

howto let ruby share data beetwen a class and its subclasses in conjuction with extend

module M def f=(x) @f= x end def f @f end end class A extend M end class B < A end A.f= 42 puts A.f puts B.f this produces 42 nil Is @f a class variable to A and B? How do I share a variable between A and B by only writing this into M? ...

Is it possible to extend a class dynamically?

I have a class which I need to use to extend different classes (up to hundreds) depending on criteria. Is there a way in PHP to extend a class by a dynamic class name? I assume it would require a method to specify extension with instantiation. Ideas? ...

php5 extend main class and use statics

why I can't do like this? <?php class core { public static $db; function __construct() { $this->db = new mysql('host', 'user', 'pw', 'db'); } } class stat extends core { public static function log() { core::$db->query("insert into mytable values(now())"); } } // do something stat::log(); ?> ...

PHP extending class properties

Hi, I have two classes in a PHP application, B extending A for example. Class A has a function which returns some of its other properties in the form of an array of SQL insert queries eg Class A { $property_a; $property_b; $property_c; $property_d; function queries() { $queries = array(); $queries[] = "INSERT INTO xxx VALUES " . $this-...

No need to extend class/library in codeigniter

I would like to check if my assumption about codeigniter is right ? We would normally extend a class when we are trying to include more functionality to the core, such as MY_Controller extends Controller, MY_Model extends Model etc... But for example, if we are in the checkout library retrieving some checkout info(eg, product_id), we c...

PHP Class and inheritance, serialization

Hi! Serialized varibale does not seem to retain its state from classes that were extended. I have a class, called directly from somewhere that accepts a serialized variable: class Main extends Admin { function __construct($serialized){ parent::__construct($serialized); } .... (omitted) } class Admin extends Page{ var $pagearg...

My control is "not allowed here because it does not extend class 'System.Web.UI.UserControl'"

Hi there So I have another noodle-scratcher (for me anyway). I'm trying to create my own custom control in a CMS I only have partial source code for (i.e. samples the vendor has supplied to me). Basically I have created a class called DataDefinitionContent which extends ControlBase. Now, from what I can garner from the metadata, Contro...

Beginner: Extending a class in C#, am I doing it wrong?

Again disclaimer disclaimer still learning C# and OOP generally so I hope you'll be patient with me :) I am currently working with a CMS that has a class called FileVersion which basically contains a list of properties pertaining to a file such as filename, filetype, size in bytes, id, date uploaded, is-latest-version, etc. A list of F...

Better way to call superclass method in ExtJS

All the ExtJS documentation and examples I have read suggest calling superclass methods like this: MyApp.MyPanel = Ext.extend(Ext.Panel, { initComponent: function() { // do something MyPanel specific here... MyApp.MyPanel.superclass.initComponent.call(this); } }); I have been using this pattern for quite some time and the ...

How to use a method from a class in another class without extending

Sorry if my question sounds weird lol I'll try to explain. I have 4 classes: Karakter, Karakters, Orc, Human. Orc and Human both extend Karakter. Karakters is an ArrayList with Karakter in it. I have a method in both Orc and Human called: public String getRace(). Now I want to use this method in Karakters?!! When I try to do this, it ...

jquery .serializeArray(); add another value on top for passing to ajax

im doing following var data = $(form).serializeArray(); // now i want to add another value on this data data.username = 'this is username'; i want to know how can i add another value after doing serializeArray(), i tried all the things i know, but nothing is getting it to work. any ideas pls. ...

Jquery: i have a function $.fn.my_function with other functions inside, how can i call them?

Suppose i have this ($ = jquery): $.fn.my_function = function() { function foo() { //do something }; function bar() { //do something other }; } I lauch this with $('.my_class').my_function(); Now, i need to call foo and bar on callback to certain events. How can i call them? ...

Strange syntax of Number methods in JavaScript

Take a look at the following code: Number.prototype.isIn = function () { for (var i = 0, j = arguments.length; i < j; ++i) { if (parseInt(this, 10) === arguments[i]) { return true; } } return false; }; var x = 2; console.log(x.isIn(1,2,3,4,5)); // <= 'true' console.log(2.isIn(1,2,3,4,5)); // <= Error: 'missing ) afte...

jQuery: extend plugin question

hi all, i'm having this simple plugin code: (function ($) { $.fn.tWeb = function () { var me = this; me.var1 = "foo"; this.done = function() { return this; } return this.done(); }; })(jQuery); var web = new jQuery.fn.tWeb(); alert(web.var1); works nice - alert(web.var1) is giving me "foo". my q...

jquery plugin $.extend

if i extend the jquery fn(like $.fn.extend) i write my plugin: (function($){ $.fn.extend({ functionName : function(){ //function returns return this.each(function(){ $(this).append("<div>text</div>"); }); } }); })(jQuery); when i want to extend jQuery nam...

PHP [OOP] : Memory allocation for Inheritance

Please see the code bellow: class A { public x = 5; public y = 6; public z = 7; } class B extends A { public m = 1; public n = 2; } $a = new A(); $b = new B() From the above code let $a is allocating x amount of memory and $b is allocating y amount of memory; Now my question is which one is correct from bellow? ...

jquery copy json object

I'm iterating through a set of json data which carries results of a few database tables. Amongst other data I have a RateTable ...erm... table, and a Resources table. The RateTable has a property name ResourceId which links to the Resources record. So, I'm iterating through my RateTable and I need to reference my Resource record and us...

extend IE with .net (VB or C#)

I want to write IE extension in .Net (VB/C#) I already have experience writing firefox addons. All I want to do is, manipulate the DOM before showing it to the user. Like remove some stuff, highlight words, etc... Is it possible to do it using .Net? Or is the only way C++/ATL and those things? I tried searching, but the only useful s...

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

Hi, I am trying to understand the jquery plugin syntax, because I want to merge two plugins into one. The blinker that also needs to be able to stop de interval or run a number of times. Anyway, is this syntax the same as jQuery.fn.extend({ everyTime: function(interval, label, fn, times) { return this.each(function() { ...

why would one pass an jquery.fn object to the jqueryobject

Hello, I am still trying to understand plugin procedure so I can write my own or adapt another. I try to learn from this plugin It sets methods with fn.extend and then passes itself(with this) to some function made in jquery.extend. jQuery.fn.extend({ everyTime: function(interval, label, fn, times) { return this.each(func...