lib/vedeu/repository/command.rb in vedeu-0.0.23 vs lib/vedeu/repository/command.rb in vedeu-0.0.24

- old
+ new

@@ -1,21 +1,18 @@ module Vedeu class Command - attr_accessor :attributes, :name, :entity, :keyword, :keypress + include Virtus.model - def initialize(attributes = {}) - @attributes = attributes || {} - @name = attributes[:name] - @entity = attributes[:entity] - @keyword = attributes.fetch(:options, {}).fetch(:keyword, '') - @keypress = attributes.fetch(:options, {}).fetch(:keypress, '') - end + attribute :name, String + attribute :entity, Class + attribute :keyword, String, default: '' + attribute :keypress, String, default: '' def execute(args = []) executable.call(*args) end def executable - proc { |*args| attributes[:entity].dispatch(*args) } + proc { |*args| entity.dispatch(*args) } end end end