Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3279202
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:33:58+00:00 2026-05-17T19:33:58+00:00

I understand my question is a bit vague but I don’t know how else

  • 0

I understand my question is a bit vague but I don’t know how else to describe it. I’ve asked in numerous places and no one seems to understand why I want to do this. But please bear with me, and I’ll explain why I want something like this.

I’m using Liquid Templates to allow users to make some dynamic pages on my site. And for those that don’t know, Liquid uses a class of theirs called LiquidDrop to expose certain items to the user. Any method in the drop can be called by the Liquid template.

class PageDrop < Liquid::Drop
  def initialize(page)
    @page = page
  end

  def name
    @page.name
  end

  def children
    PagesDrop.new(@page.children)
  end
end
class PagesDrop < Liquid::Drop
  def initialize(pages)
    @pages = pages
  end

  def group_by
    GroupByDrop.new(@pages)
  end

  def all
    @pages.all
  end

  def size
    @pages.size
  end
end

For example, I want to be able to do this:

@page_drop = PageDrop.new(@page)
@page_drop.children # to get an array of children

instead of

@page_drop.children.all

Why do I have a pages drop?

Because I want to be able to cleanly split up the methods I can do to an array of pages, and methods I can do to a single page. This allows me to group pages like so:

@page_drop.children.group_by.some_method_here_that_the_group_drop_contains

To make it simpler for my users, I don’t want them to have to think about adding “all” or not to a drop instance to get the “default” object/s that it contains. To reiterate:

@pages_drop = PagesDrop.new(Page.all)

@pages_drop == @pages_drop.pages #I want this to be true, as well as
@pages_drop == @pages_drop.all

Where did I get this idea?

In Rails, a scope (association object) (@person.friends) seems to return the array when you do certain things to it: @person.friends.each, for person in @person.friends

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:33:58+00:00Added an answer on May 17, 2026 at 7:33 pm

    This isn’t really possible. When you write @instance you aren’t really calling an instance as you describe, you’re getting a reference to the object that @instance refers to.

    The reason it seems to work with the collections for Rails’ associations is that the the association objects are instances of Array that have had some of their methods overridden.

    I would consider removing PagesDrop and using the group_by(&:method) syntax if you want a concise way to express groupings. If you do want to keep it then you can get some way towards what you want by implementing each and [] on PagesDrop and having them delegate to @pages. That will let you use @page_drop.children in for loops, for instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this question has been asked loads of times, but I have
While I understand this question is fairly vague since I'm not giving you all
I understand that the question is rather hard to understand, I didn't know how
This is probably an easy question, but I want to understand better how Apache
( This question about refactoring F# code got me one down vote, but also
The question is simple: I cannot understand the Zipper data structure. My question is
This question is for the java language in particular. I understand that there is
This is just a question to help me understand CSS rendering better. Lets say
There was an interesting question in a practice test that I did not understand
This is a follow up question to This Question . I like (and understand)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.