Class: RemoteFactoryGirl::JsonToActiveResource

Inherits:
Object
  • Object
show all
Defined in:
lib/remote_factory_girl/json_to_active_resource.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, config = {}) ⇒ JsonToActiveResource

Returns a new instance of JsonToActiveResource.



12
13
14
15
16
# File 'lib/remote_factory_girl/json_to_active_resource.rb', line 12

def initialize(json, config = {})
  raise 'ActiveResource not defined' if !defined?(ActiveResource)
  @json   = json
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/remote_factory_girl/json_to_active_resource.rb', line 8

def config
  @config
end

#jsonObject (readonly) Also known as: to_hash

Returns the value of attribute json.



8
9
10
# File 'lib/remote_factory_girl/json_to_active_resource.rb', line 8

def json
  @json
end

Class Method Details

.convert(json, config = {}) ⇒ Object



4
5
6
# File 'lib/remote_factory_girl/json_to_active_resource.rb', line 4

def self.convert(json, config = {})
  new(json, config)
end

Instance Method Details

#resource(resource) ⇒ Object



18
19
20
# File 'lib/remote_factory_girl/json_to_active_resource.rb', line 18

def resource(resource) 
  resource.find(id)
end