Documentation improvements #368

Closed
kristianmandrup opened this Issue Dec 6, 2012 · 8 comments

Comments

Projects
None yet
3 participants
@kristianmandrup

The decorated_association example should mention that you can specify a with: option, that defines the specific Decorator class to be used for the association in question. For any large project (more than say +10 models) this quickly becomes an issue.

Suggestion: The inclusion of the LazyHelper module could perhaps as well be encapsulated in a Draper::LazyDecorator in order to remove a little code noise?

class MyDecorator < Draper::LazyDecorator
...
end
@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Dec 7, 2012

Member

Yep. Docs need lots of work before release.

I like the idea of a LazyDecorator, in a way, but it seems to me that the module is better. Laziness is more of a role than it is a subclass.

Member

steveklabnik commented Dec 7, 2012

Yep. Docs need lots of work before release.

I like the idea of a LazyDecorator, in a way, but it seems to me that the module is better. Laziness is more of a role than it is a subclass.

@kristianmandrup

This comment has been minimized.

Show comment
Hide comment
@kristianmandrup

kristianmandrup Dec 7, 2012

How about this then?

class Draper::Decorator
    class << self
      alias_method :decorate, :new

      def self.lazy!
        self.send :include, Draper::LazyHelpers
      end
    end
end

class MyDecorator < Draper::Decorator
  lazy!
end

or perhaps even: roles :lazy ?

How about this then?

class Draper::Decorator
    class << self
      alias_method :decorate, :new

      def self.lazy!
        self.send :include, Draper::LazyHelpers
      end
    end
end

class MyDecorator < Draper::Decorator
  lazy!
end

or perhaps even: roles :lazy ?

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Dec 7, 2012

Member

Seems like a lot of effort to drop off like ten characters. Hm. Are there other roles a Decorator might play?

Member

steveklabnik commented Dec 7, 2012

Seems like a lot of effort to drop off like ten characters. Hm. Are there other roles a Decorator might play?

@kristianmandrup

This comment has been minimized.

Show comment
Hide comment
@kristianmandrup

kristianmandrup Dec 7, 2012

Well, I just feel it is kind of dirty having to add that include (more like 10 chars?) to most decorators. But hey, I will just make my own patch. I just thought other might have the same "concern". And sure, I think it would make sense to be able to register different kinds of roles with a Decorator, but then, I would just use my concerned gem for those cases and perhaps wrap it inside a roles macro. That is just my style of coding... I like to read my "published" code like a good book, while hiding away all the nitty-gritty details behind a magic curtain ;)

Well, I just feel it is kind of dirty having to add that include (more like 10 chars?) to most decorators. But hey, I will just make my own patch. I just thought other might have the same "concern". And sure, I think it would make sense to be able to register different kinds of roles with a Decorator, but then, I would just use my concerned gem for those cases and perhaps wrap it inside a roles macro. That is just my style of coding... I like to read my "published" code like a good book, while hiding away all the nitty-gritty details behind a magic curtain ;)

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Dec 7, 2012

Member

I guess I'm not sure that it's 'most', really. I personally don't even like LazyHelpers, I wouldn't have included them at all, but @jcasimir already did...

Member

steveklabnik commented Dec 7, 2012

I guess I'm not sure that it's 'most', really. I personally don't even like LazyHelpers, I wouldn't have included them at all, but @jcasimir already did...

@kristianmandrup

This comment has been minimized.

Show comment
Hide comment
@kristianmandrup

kristianmandrup Dec 7, 2012

I see you point, but then again h.content_tag doesn't really feel that natural. Ruby is supposed to be more DSL like than fx Java IMO ;)

I see you point, but then again h.content_tag doesn't really feel that natural. Ruby is supposed to be more DSL like than fx Java IMO ;)

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Dec 7, 2012

Member

Right, but polluting the global namespace is bad. See rspec changing to the expect syntax, for example. DSL != 'define methods on Object'.

Member

steveklabnik commented Dec 7, 2012

Right, but polluting the global namespace is bad. See rspec changing to the expect syntax, for example. DSL != 'define methods on Object'.

@kristianmandrup

This comment has been minimized.

Show comment
Hide comment
@kristianmandrup

kristianmandrup Dec 7, 2012

I would never opt to pollute the global namespace!!! Of course not ;)
Same goes for any language where this is even possible, such as Javascript.

I would never opt to pollute the global namespace!!! Of course not ;)
Same goes for any language where this is even possible, such as Javascript.

@haines haines closed this in 52360b6 Dec 31, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment