Module: Zobi

Defined in:
lib/zobi.rb,
lib/zobi/engine.rb,
lib/zobi/scoped.rb,
lib/zobi/version.rb,
lib/zobi/discover.rb,
lib/zobi/included.rb,
lib/zobi/decorated.rb,
lib/zobi/inherited.rb,
lib/zobi/paginated.rb,
lib/zobi/controlled_access.rb,
lib/zobi/parameters_sanitizer.rb,
app/decorators/zobi/resource_decorator.rb,
app/decorators/zobi/collection_decorator.rb,
lib/zobi/responders/pagination_responder.rb

Defined Under Namespace

Modules: ControlledAccess, Decorated, Included, Inherited, InstanceMethods, Paginated, Responders, Scoped Classes: CollectionDecorator, Discover, Engine, ParametersSanitizer, ResourceDecorator

Constant Summary collapse

BEHAVIORS =
[:inherited, :scoped, :included, :paginated, :controlled_access, :decorated].freeze
VERSION =
"5.0.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



8
9
10
11
# File 'lib/zobi.rb', line 8

def self.extended base
  base.helper_method :collection, :resource, :resource_class,
    :collection_path, :new_resource_path, :edit_resource_path, :resource_path
end

Instance Method Details

#behavior_included?(name) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/zobi.rb', line 24

def behavior_included? name
  ancestors.include?(behavior_module(name))
end

#behavior_module(name) ⇒ Object



20
21
22
# File 'lib/zobi.rb', line 20

def behavior_module name
  "Zobi::#{name.to_s.camelize}".constantize
end

#behaviors(*behaviors) ⇒ Object



13
14
15
16
17
18
# File 'lib/zobi.rb', line 13

def behaviors *behaviors
  (BEHAVIORS & behaviors).each do |behavior|
    send(:include, behavior_module(behavior))
  end
  send(:include, ::Zobi::InstanceMethods)
end