Code Monkey home page Code Monkey logo

simple_states's People

Contributors

anarosas avatar clemens avatar ifesdjeen avatar j-wilkins avatar mattetti avatar michaelklishin avatar ndbroadbent avatar sarahhodne avatar stevenbristol avatar svenfuchs 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

simple_states's Issues

Depecation warning

# Running:
..../skipped/.bundle/gems/gems/simple_states-2.0.0/lib/simple_states/event.rb:44: warning: Hash#index is deprecated; use Hash#key
/skipped/.bundle/gems/gems/simple_states-2.0.0/lib/simple_states/event.rb:44: warning: Hash#index is deprecated; use Hash#key
....

ruby 2.2.3

ActiveModel::MissingAttributeError: missing attribute: state

When i use select in active record query wich not include attribute state, instantiate record model raise exception

Project.select(:id).first
  Project Load (0.1ms)  SELECT  "projects"."id" FROM "projects" ORDER BY "projects"."id" ASC LIMIT ?  [["LIMIT", 1]]
ActiveModel::MissingAttributeError: missing attribute: state
    from /home/damir/project/.bundle/gems/gems/activerecord-5.0.0.beta1/lib/active_record/attribute_methods/read.rb:78:in `block in _read_attribute'
    from /home/damir/project/.bundle/gems/gems/activerecord-5.0.0.beta1/lib/active_record/attribute_set.rb:42:in `block in fetch_value'
    from /home/damir/project/.bundle/gems/gems/activerecord-5.0.0.beta1/lib/active_record/attribute.rb:194:in `value'
    from /home/damir/project/.bundle/gems/gems/activerecord-5.0.0.beta1/lib/active_record/attribute_set.rb:42:in `fetch_value'
    from /home/damir/project/.bundle/gems/gems/activerecord-5.0.0.beta1/lib/active_record/attribute_methods/read.rb:78:in `_read_attribute'
    from /home/damir/project/.bundle/gems/gems/activerecord-5.0.0.beta1/lib/active_record/attribute_methods/read.rb:48:in `__temp__3747164756'
    from /home/damir/project/.bundle/gems/gems/simple_states-2.0.0/lib/simple_states.rb:47:in `state'
    from /home/damiconst.after_initialize(:init_state)r/project/.bundle/gems/gems/simple_states-2.0.0/lib/simple_states.rb:39:in `init_stat

dig in to code problem in callback after_initialize(:init_state)

  def init_state
    singleton_class.send(:include, self.class::States) unless self.class.respond_to?(:prepend)
    self.state = self.class.initial_state if self.state.nil?
  end

  def state
    state = super
    state.to_sym if state
  end

self.state.nil?

does not check that the attributes contain state

Multiple target states

In the event of :finish, how do you decide between target states :passed and :failed in the README example?

ActiveRecord

The gem is awesome but comes with a small issue: In the Readme, there's a part where you say you'll see the ActiveRecord integration later, but that later never comes.
If you please add an integration example would be great.

Thanks in advance!

Multiple events with the same name.

Please correct me if I am wrong, but at the moment it is not possible to define multiple events with the same name. It would be good if you were allowed to do this, as long as there were not multiple events with the same name stemming from the same state. Ie. I would like to define:

 event :close, from: :created, to: :closed
 event :close, from: :open, to: :closed

But am having to define

 event :close_created, from: :created, to: :closed
 event :close_open, from: :open, to: :closed

This could be implemented by defining event method names by concatenating their name and starting state. Would you accept a PR with this proposed method, or do you have any other opinions?

Thanks
Jack

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.