Giter Site home page Giter Site logo

Comments (4)

dchacke avatar dchacke commented on June 12, 2024 1

That all sounds good to me. I vote calling it logidze_versions instead of disabling it by default. You can always just do

def arbitrary_versions_attr
  logidze_versions
end

and so no custom syntax is required.

from logidze.

palkan avatar palkan commented on June 12, 2024

Nope, there is no API for that.

Do you have an idea how it could look like? And what is your use case?

from logidze.

dchacke avatar dchacke commented on June 12, 2024

Something like post.versions would be fine. It could return an array with the original as the first element and then all subsequent versions in the order they were created.

I host a blog and need to list all revisions to a post with word-based diffs.

from logidze.

palkan avatar palkan commented on June 12, 2024

It could return an array with the original as the first element and then all subsequent versions in the order they were created

That's an interesting question whether the current version should be included or not 🤔

And I'm thinking of having an enumerator instead of returning an Array right away (since created many records could affect performance). Something like this:

post.versions #=> Enumerator

# you can use take to return all
post.versions.take

# or you take a few or call any Enumerable method
post.versions.take(2)

post.versions.find do
  _1.title == "old title"
end

# we can also add options
post.versions(reverse: true) # from older to newer
post.versions(include_self: true) # return self as the first one (default) or the last one record (if reverse: true)

And we should either use a less common name, say, post.logidze_versions or make this feature disabled by default and allow to configure the name. For example:

class Post < ApplicationRecord
  # add #versions method
  has_logidze versions_accessor: true

  # use a custom name
  has_logidze versions_accessor: :log_versions
end

WDYT? Am I missing something?

from logidze.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.