Sha256: deb365fdff1bd3e8b2d525f35c329de1b656f67a99d808f1e4b9172ed7850636

Contents?: true

Size: 901 Bytes

Versions: 5

Compression:

Stored size: 901 Bytes

Contents

## Lux::Controller - Simplified Rails like view controllers

Controllers are Lux view models

* all cells shoud inherit from Lux::Controller
* `before`, `before_action` and `after` class methods supportd
* instance_method `on_error` is supported
* calls templates as default action, behaves as Rails controller.

### Example code

```ruby
require 'lux-fw'

class Main::RootController < Lux::Controller
  # action to perform before
  before do
    @org = Org.find @org_id if @org_id
    # ...
  end
  # action to perform before

  before_action do |action_name|
    next if action_name == :index
    # ...
  end

  ###

  mock :show # mock `show` action

  def index
    render text: 'Hello world'
  end

  def foo
    # renders ./app/views/main/root/foo.(haml, erb)
  end

  def baz
    send_file local_file, file_name: 'local.txt'
  end

  def bar
    render json: { data: 'Bar text' }
  end

end
```

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lux-fw-0.5.37 ./lib/lux/controller/README.md
lux-fw-0.5.36 ./lib/lux/controller/README.md
lux-fw-0.5.35 ./lib/lux/controller/README.md
lux-fw-0.5.34 ./lib/lux/controller/README.md
lux-fw-0.5.33 ./lib/lux/controller/README.md