Giter Site home page Giter Site logo

adornable's People

Contributors

adlugopolski avatar kjleitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

adornable's Issues

Merge the syntax for :memoize and :memoize_for_arguments

Is there a technical reason to separate syntax to memoize methods with or without arguments? If method accepts any arguments it doesn't make much sense to memoize the same result for different arguments. I used to use the Memoist gem. The syntax there is the same regardless if the method accepts arguments. Arguments passed to the methods are always used as a part of the cache key.

I am not sure if this qualifies as the issue per se. I guess this is a suggestion to just use one syntax for both variants. :-)

decorators inside singleton classes

Why can't I add decortors inside singleton classes? I get that the error is saying name isn't defined for the singleton class, but why do we need it?

require 'adornable'

class Decorators
  def self.time(context, stat:, &block)
    start_time = Time.now.utc
    begin
      return yield
    ensure
      end_time = Time.now.utc
      duration = (end_time - start_time) * 1000.0
      puts "#{stat} #{duration}ms"
    end
  end
end

class Dog
  class << self
    extend Adornable

    decorate :time, from: Decorators, stat: 'bark'
    def bark
      sleep 1.3
    end
  end
end

Dog.bark
Traceback (most recent call last):
        3: from adornable.rb:16:in `<main>'
        2: from adornable.rb:17:in `<class:Dog>'
        1: from adornable.rb:20:in `singleton class'
/Users/jaredw/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/adornable-1.2.0/lib/adornable.rb:18:in `decorate': Decorator name must be provided. (Adornable::Error::InvalidDecoratorArguments)
  def decorate(decorator_name, from: nil, defer_validation: false, **decorator_options)
    if Adornable::Utils.blank?(name)
      raise Adornable::Error::InvalidDecoratorArguments, "Decorator name must be provided."
    end

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.