Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove activemodel dependency

  • Loading branch information...
commit 6cc1263f2ef75b2c30d60685bfcdb12e921579ca 1 parent 4975e20
@karmajunkie authored
Showing with 5 additions and 29 deletions.
  1. +3 −22 lib/imperator/command.rb
  2. +2 −7 spec/imperator/command_spec.rb
View
25 lib/imperator/command.rb
@@ -1,21 +1,7 @@
-require 'active_model'
require 'virtus'
class Imperator::Command
- include ActiveModel::Validations
- extend ActiveModel::Callbacks
include Virtus
- if defined? ActiveModel::Serializable
- include ActiveModel::Serializable::JSON
- include ActiveModel::Serializable::XML
- else
- include ActiveModel::Serializers::JSON
- include ActiveModel::Serializers::Xml
- end
-
- define_model_callbacks :create, :perform, :initialize
-
-
def self.action(&block)
define_method(:action, &block)
end
@@ -41,13 +27,7 @@ def commit
end
def initialize(*)
- run_callbacks :initialize do
- super
- end
- end
-
- def dump
- attributes.to_json
+ super
end
def self.load(command_string)
@@ -69,6 +49,7 @@ def action
end
def perform
- run_callbacks(:perform) { action }
+ action
end
+
end
View
9 spec/imperator/command_spec.rb
@@ -1,4 +1,5 @@
require 'imperator'
+require 'rspec/mocks'
describe Imperator::Command do
describe "actions" do
@@ -6,7 +7,7 @@ class CommandTestException < Exception; end
context "using DSL " do
class DSLTestCommand < Imperator::Command
action do
- raise CommandTestException.new
+ raise CommandTestException.new
end
end
@@ -53,12 +54,6 @@ class AttributeCommand < Imperator::Command
command = AttributeCommand.new :gets_default => "bar"
command.gets_default.should == "bar"
end
-
- it "will create attributes as json" do
- command = AttributeCommand.new
- command.as_json.should == { "gets_default" => "foo",
- "declared_attr" => nil}
- end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.