Module: Biovision::Components::Base::ComponentStories

Defined in:
app/lib/biovision/components/base/component_stories.rb

Overview

Methods for handling component stories

Instance Method Summary collapse

Instance Method Details

#perform_story(story_slug, story_parameters, entity = nil) ⇒ Object

Parameters:

  • story_slug (String)
  • story_parameters (Hash)
  • entity (ApplicationRecord|String|nli) (defaults to: nil)


24
25
26
# File 'app/lib/biovision/components/base/component_stories.rb', line 24

def perform_story(story_slug, story_parameters, entity = nil)
  story(story_slug, entity).perform(story_parameters)
end

#story(story_slug, entity = nil) ⇒ Object

Parameters:

  • story_slug (String)
  • entity (ApplicationRecord|nil) (defaults to: nil)


17
18
19
# File 'app/lib/biovision/components/base/component_stories.rb', line 17

def story(story_slug, entity = nil)
  story_class(story_slug).new(self, entity)
end

#story_class(story_slug) ⇒ Object

Parameters:

  • story_slug (String)


9
10
11
12
13
# File 'app/lib/biovision/components/base/component_stories.rb', line 9

def story_class(story_slug)
  namespace = "biovision/components/#{self.class.slug}"
  handler_name = "#{namespace}/stories/#{story_slug}_story".classify
  handler_name.safe_constantize || Biovision::Stories::ComponentStory
end