module BiteHelper

Public Instance Methods

text_bite(identifier, options) click to toggle source
# File lib/bites/bite_helper.rb, line 2
def text_bite(identifier, options)
  bite = Bite.find_by(identifier: identifier)
  return bite_form(bite) if @bite_authentication
  return Bite.create(identifier: identifier, text: options.default).text if bite.nil?
  return bite.text unless bite.text.blank?
  return options[:default] if options.present?
end

Private Instance Methods

bite_form(bite) click to toggle source
# File lib/bites/bite_helper.rb, line 10
        def bite_form(bite)
  render(
    inline: "<%= form_for bite do |f| %><%= f.text_area :text %><%= f.submit 'Update' %><% end %>",
    locals: { bite: bite }
  )
end