Module: RemoteFactoryGirl

Defined in:
lib/remote_factory_girl.rb,
lib/remote_factory_girl/http.rb,
lib/remote_factory_girl/config.rb,
lib/remote_factory_girl/version.rb,
lib/remote_factory_girl/exceptions.rb,
lib/remote_factory_girl/hash_to_dot.rb,
lib/remote_factory_girl/config_applier.rb,
lib/remote_factory_girl/remotes_config.rb,
lib/remote_factory_girl/json_to_active_resource.rb,
lib/remote_factory_girl/factory_girl_json_parser.rb

Defined Under Namespace

Classes: Config, ConfigApplier, FactoryGirlJsonParser, HashToDot, Http, JsonToActiveResource, RemoteFactoryGirl, RemoteFactoryGirlConfigError, RemotesConfig

Constant Summary collapse

VERSION =
"1.1.0"

Class Method Summary collapse

Class Method Details

.config(remote_name = remotes_config.default_remote_name) ⇒ Object



51
52
53
# File 'lib/remote_factory_girl.rb', line 51

def self.config(remote_name = remotes_config.default_remote_name)
  remotes_config.remotes[remote_name]
end

.configure(remote_name = remotes_config.default_remote_name, config = Config) {|configuration| ... } ⇒ Object

Yields:

  • (configuration)


27
28
29
30
31
# File 'lib/remote_factory_girl.rb', line 27

def self.configure(remote_name = remotes_config.default_remote_name, config = Config, &block)
  configuration = Config.new
  yield(configuration)
  remotes_config.remotes[remote_name] = configuration
end

.create(factory_name, attributes = {}, config_applier = ConfigApplier, http = Http) ⇒ Object



39
40
41
42
43
44
# File 'lib/remote_factory_girl.rb', line 39

def self.create(factory_name, attributes = {}, config_applier = ConfigApplier, http = Http)
  config_for_remote = config(remotes_config.current_remote)
  factory = RemoteFactoryGirl.new(config_for_remote)
  factory.create(factory_name, attributes, http)
  config_applier.apply_config(factory.response.to_hash, config_for_remote.to_hash)
end

.factories(params = {}, http = Http) ⇒ Object



33
34
35
36
37
# File 'lib/remote_factory_girl.rb', line 33

def self.factories(params = {}, http = Http)
  config_for_remote = config(remotes_config.current_remote)
  factory = RemoteFactoryGirl.new(config_for_remote)
  factory.factories(params, http).to_hash
end

.remotes_configObject



55
56
57
# File 'lib/remote_factory_girl.rb', line 55

def self.remotes_config
  @remotes_config ||= RemotesConfig.new
end

.with_remote(remote_name = remotes_config.default_remote_name) ⇒ Object



46
47
48
49
# File 'lib/remote_factory_girl.rb', line 46

def self.with_remote(remote_name = remotes_config.default_remote_name)
  remotes_config.current_remote = remote_name
  self
end