Hi everybody,

	the whole issues comes from here:
http://github.com/bolthar/freightrain/blob/master/lib/freightrain/freight_view_model.rb
FreightViewModel is part of the framework, and if you're using it that's
the way you should do it:

class MyViewModel < FreightViewModel

...

end

what i don't like is that if you want to make _your_ viewmodel do stuff
on initialize, which is usual, you have to write your initialize method
as such:

def initialize
  super
  #your stuff here
end

otherwise the automagical initialization (like building views, hooking
to services, etc) doesn't work, because the constructor of
FreightViewModel (that is the one taking care of all this) doesn't get
called. 
I know this is not extremely important (you just have to remind to call
super) but i'd prefer not to have that hassle : i forget it myself more
than often.


-- 
Andrea Dallera
http://github.com/bolthar/freightrain
http://usingimho.wordpress.com


On Mon, 2010-03-15 at 23:50 +0900, Marvin Glker wrote:
> Andrea Dallera wrote:
> > this should print out "from parent"
> 
> Maybe I can't follow you, but that's exactly what's super for:
> -------------------------------------------
> irb(main):001:0> class Parent
> irb(main):002:1> attr_reader :test_value
> irb(main):003:1> def initialize
> irb(main):004:2> @test_value = "from parent"
> irb(main):005:2> end
> irb(main):006:1> end
> => nil
> irb(main):007:0> class Child < Parent
> irb(main):008:1> def initialize
> irb(main):009:2> super
> irb(main):010:2> p @test_value
> irb(main):011:2> end
> irb(main):012:1> end
> => nil
> irb(main):013:0> child = Child.new
> "from parent"
> => #<Child:0x0000000183c140 @test_value="from parent">
> irb(main):014:0>
> -------------------------------------------
> Why don't you want it?
> 
> Marvin