Class: RemoteFactoryGirl::Config
- Inherits:
-
Object
- Object
- RemoteFactoryGirl::Config
- Defined in:
- lib/remote_factory_girl/config.rb
Instance Attribute Summary collapse
-
#home ⇒ Object
Returns the value of attribute home.
-
#https ⇒ Object
Returns the value of attribute https.
-
#return_as_active_resource ⇒ Object
Returns the value of attribute return_as_active_resource.
-
#return_response_as ⇒ Object
Returns the value of attribute return_response_as.
-
#return_with_root ⇒ Object
Returns the value of attribute return_with_root.
Instance Method Summary collapse
- #has_home? ⇒ Boolean
- #home_url ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #raise_if_host_not_set ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ Config
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
#home ⇒ Object
Returns the value of attribute home.
6 7 8 |
# File 'lib/remote_factory_girl/config.rb', line 6 def home @home end |
#https ⇒ Object
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_resource ⇒ Object
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_as ⇒ Object
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_root ⇒ Object
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
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_url ⇒ Object
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_set ⇒ Object
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_hash ⇒ Object
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 |