Module: MontageRails

Defined in:
lib/montage_rails.rb,
lib/montage_rails/base.rb,
lib/montage_rails/errors.rb,
lib/montage_rails/boolean.rb,
lib/montage_rails/railtie.rb,
lib/montage_rails/version.rb,
lib/montage_rails/relation.rb,
lib/montage_rails/base/column.rb,
lib/montage_rails/mock_server.rb,
lib/montage_rails/query_cache.rb,
lib/montage_rails/log_subscriber.rb,
lib/montage_rails/application_resource.rb

Defined Under Namespace

Classes: ApplicationResource, AttributeMissingError, Base, Boolean, LogSubscriber, MockServer, ModelGenerator, MontageAPIError, QueryCache, Railtie, Relation, RelationError

Constant Summary collapse

VERSION =
"1.0.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.debuggerObject

Returns the value of attribute debugger.



17
18
19
# File 'lib/montage_rails.rb', line 17

def debugger
  @debugger
end

.domainObject

Returns the value of attribute domain.



17
18
19
# File 'lib/montage_rails.rb', line 17

def domain
  @domain
end

.no_cachingObject

Returns the value of attribute no_caching.



17
18
19
# File 'lib/montage_rails.rb', line 17

def no_caching
  @no_caching
end

.passwordObject

Returns the value of attribute password.



17
18
19
# File 'lib/montage_rails.rb', line 17

def password
  @password
end

.tokenObject

Returns the value of attribute token.



17
18
19
# File 'lib/montage_rails.rb', line 17

def token
  @token
end

.use_mock_serverObject

Returns the value of attribute use_mock_server.



17
18
19
# File 'lib/montage_rails.rb', line 17

def use_mock_server
  @use_mock_server
end

.usernameObject

Returns the value of attribute username.



17
18
19
# File 'lib/montage_rails.rb', line 17

def username
  @username
end

Class Method Details

.boot_serverObject



26
27
28
# File 'lib/montage_rails.rb', line 26

def boot_server
  test_server.boot if Rails.env.test?
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (MontageRails)

    the object that the method was called on



19
20
21
22
23
24
# File 'lib/montage_rails.rb', line 19

def configure
  yield self
  validate
  get_token unless token
  boot_server if use_mock_server
end

.connectionObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/montage_rails.rb', line 35

def connection
  @connection ||= begin
    Montage::Client.new do |c|
      c.token = token
      c.domain = domain
      c.environment = Rails.env
      c.test_url = "http://#{test_server.host}:#{test_server.port}/montage_rails_mock"
    end
  end
end

.notify(caller, &block) ⇒ Object



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

def notify(caller, &block)
  ActiveSupport::Notifications.instrument("reql.montage_rails", caller.payload) do
    yield
  end
end

.test_serverObject



30
31
32
33
# File 'lib/montage_rails.rb', line 30

def test_server
  require 'capybara/rails' if defined?(Rails)
  @test_server ||= Capybara::Server.new(Rails.application)
end