Class: RemoteFactoryGirl::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



8
9
10
11
12
13
14
# File 'lib/remote_factory_girl/config.rb', line 8

def initialize
  @return_response_as        = :as_hash
  @return_with_root          = true
  @return_as_active_resource = false
  @home                      = default_home_config
  @https                     = false
end

Instance Attribute Details

#homeObject

Returns the value of attribute home.



6
7
8
# File 'lib/remote_factory_girl/config.rb', line 6

def home
  @home
end

#httpsObject

Returns the value of attribute https.



6
7
8
# File 'lib/remote_factory_girl/config.rb', line 6

def https
  @https
end

#return_as_active_resourceObject

Returns the value of attribute return_as_active_resource.



6
7
8
# File 'lib/remote_factory_girl/config.rb', line 6

def return_as_active_resource
  @return_as_active_resource
end

#return_response_asObject

Returns the value of attribute return_response_as.



6
7
8
# File 'lib/remote_factory_girl/config.rb', line 6

def return_response_as
  @return_response_as
end

#return_with_rootObject

Returns the value of attribute return_with_root.



6
7
8
# File 'lib/remote_factory_girl/config.rb', line 6

def return_with_root
  @return_with_root
end

Instance Method Details

#has_home?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/remote_factory_girl/config.rb', line 41

def has_home?
  !home[:host].nil? && !(home[:host] == '') && !home[:end_point].nil? && !(home[:end_point] == '')
end

#home_urlObject



20
21
22
23
24
25
26
27
# File 'lib/remote_factory_girl/config.rb', line 20

def home_url
  raise_if_host_not_set
  if home[:port]
    "#{ hyper_text_transfer_protocal }://#{ home.fetch(:host) }:#{ home.fetch(:port) }#{ home.fetch(:end_point) }"
  else
    "#{ hyper_text_transfer_protocal }://#{ home.fetch(:host) }#{ home.fetch(:end_point) }"
  end
end

#raise_if_host_not_setObject



37
38
39
# File 'lib/remote_factory_girl/config.rb', line 37

def raise_if_host_not_set
  raise RemoteFactoryGirlConfigError.new('RemoteFactoryGirl.config.home[:host] and RemoteFactoryGirl.config.home[:end_point] can not be nil') unless has_home?
end

#to_hashObject



29
30
31
32
33
34
35
# File 'lib/remote_factory_girl/config.rb', line 29

def to_hash
  { home:                      home,
    home_url:                  home_url,
    return_response_as:        return_response_as,
    return_with_root:          return_with_root,
    return_as_active_resource: return_as_active_resource }
end