Module: DataMapper::Is::ReadOnly

Defined in:
lib/dm-is-read_only/is/read_only.rb,
lib/dm-is-read_only/is/read_only/state.rb,
lib/dm-is-read_only/is/read_only/exceptions/error.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods Classes: Error, State

Instance Method Summary collapse

Instance Method Details

#is_read_only(options = {}) ⇒ Object

Makes a Model and all resources of the model, read-only.

Examples:

Disable both migrations and mutability

is :read_only

Do not disable migrations

is :read_only, :migrations => true

Do not disable mutability

is :read_only, :mutable => true

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :migrations (Boolean)

    Specifies that migrations should be left enabled.

  • :mutable (Boolean)

    Specifies that the resource should remain mutable.



27
28
29
30
31
32
33
34
35
# File 'lib/dm-is-read_only/is/read_only.rb', line 27

def is_read_only(options={})
  unless options[:migrations]
    extend DataMapper::Is::ReadOnly::ClassMethods
  end

  unless options[:mutable]
    include DataMapper::Is::ReadOnly::InstanceMethods
  end
end